In PHP, if you want to replace the commas between Chinese characters in a piece of data with full-width ones, how should you do it? 100 points

For example 1,9,admin, you are my lover, I am your lover, right, 20141109,769 Replace the half-width commas between those Chinese sentences Make full-width commas Thank you Reply to discussion (solution) $s = ‘1,9,admin, you are my lover, I am your lover, right, 20141109,769’;//Any of the following sentences can echo str_replace(‘ ,’, ‘, ‘, $s);echo strtr($s, array(‘,’ => ‘,’));echo join(‘,’, explode(‘,’, $s)); $s = ‘1,9,admin, you are my lover, I am your lover, right, 20141109,769’;//Any of the following sentences can echo str_replace(‘,’, ‘,’, $s);echo strtr($s, array(‘,’ => ‘, ‘));echo join(‘,’, explode(‘,’, $s)); Then you change other things too Well, it’s between Chinese $s = ‘1,9,admin, you are my lover, I am your lover, right, 20141109,769’ ;echo preg_replace(‘/([\x80-\xff]),([\x80-\xff])/’, ‘$1,$2’, $s);

In php, the results of the string echo and var_damp that I re-spliced ​​are different? [I posted the wrong post just now]-php tutorial

As shown in the picture above, the top is what comes out of echo, and the bottom is what comes out of var_damp. Why is this happening? Help Help Reply to discussion (solution ) Check the source code of the web page and you will find that they are all the same Check the source code of the web page and you will find that It’s all the same Yes, yes, it’s indeed the same, thank you Can the xml format be echoed directly… What’s the difference? Why didn’t I see it? The browser has filtered the tag pairs for you, why don’t you thank it properly. . . Can the xml format be echoed directly… What should I do? I need to use these tags What’s the difference? Why didn’t I see the tag. The browser has filtered the tag pairs for you, why don’t you thank it properly. . . Does this have anything to do with the browser? I need to use these tags, and I won’t thank him if they are filtered out! The html tag is enclosed in , so your browser will interpret it as an html tag What does this have to do…

In php, there is a multi-dimensional array $b=array(); and a string $a='[1][1]’; is there any way to get the value at position $a from $b?

In other words, can we use $a to express the form of $b[1][1]. Reply to discussion (solution) $a is constantly changing, and it may be $a='[1][1][1]’; Does anyone know? No, you need to split $a into an array and loop. The form of variable variables should not work <?php $a = array(array(1, 2, 3)); $ b = ‘[0][2]’; $c = ‘$a’ . $b; eval(‘$d=’ . $c . ‘;’); echo $d; ?> <?php $a = array(array(1, 2, 3)); $b = ‘[0][2]’; $c = ‘$a’ . $b; eval(‘$d=’ . $ c . ‘;’); echo $d; ?> Although the use of eval is prohibited, this method can only be used, thank you! I figured it out by myself <?php $b=array(array(1, 2, 3)); $a=”[0][2]”; echo eval(“return \$b$a;”); exit; ?>

In PHP, why are variables defined in trycatch blocks also available outside the block?

function f() { try { $a = new obj; } catch (Exception $e) { echo $e->getMessage(); } $a->func( );} As above, the $a variable can still call func(), that is, it can still be accessed outside the try{} block. My idea is because $a is generated by new Object, the $a object memory is not recycled when $a calls the func function. PHP masters, please give me some advice on the reason for this phenomenon. Reply to discussion (solution) In the try block, just define the content inside if there is an exception. Do the specified operation. It is not a function in itself. If an exception is thrown, the script in the try statement will stop executing, and then immediately switch to executing the script in the catch statement. Therefore, the above code, leaving aside exception handling, is equivalent to function f() { $a = new obj; $a->func();} The try catch structure is just a program block for handling exceptions Formally speaking, it is the same as if else, while, and for , there is no difference between the foreach structure In the try block, it just defines the content inside and needs to perform specified operations if there…

In PHP, if(NULL>”) and if(‘a”>”) return true or false?

In PHP, if(NULL>”) and if(‘a”>”) return true or false? Reply to discussion (solution) NULL>” is false (false) ‘a’>” is true (true)

In PHP, $a=1;$b=&$a;$c=(++$a)+(++$a)+(++$a); why is $c equal to 10?

Reply content: Stop discussing undefined behavior PHP: Operator Precedence First, you need to understand the knowledge about reference counting and variable separation in the PHP source code. Then let’s look at opcode: line #* E I O op fetch ext return operands ————————————————– ———————————- 3 0 E > ASSIGN !0, 1 4 1 ASSIGN_REF !1, !0 5 2 PRE_INC $2 !0 3 PRE_INC $3 !0 4 ADD ~4 $2, $3 5 PRE_INC $5 !0 6 ADD ~6 ~4, $5 7 ASSIGN !2, ~6 6 8 SEND_VAR !2 9 DO_FCALL 1 ‘var_dump’ 10 > RETURN 1 This can be said to be a bug in versions below PHP7 Why doesn’t anyone explain? Is there some difference between 7 and 5? In php7,$a=1;$b=&$a;$c=(++$a)+(++$a)+(++$a); the result $c is 9. In php5, the result is 10. In php5:$a=1;$b=&$a;$c=(++$a)+(++$a)+(++$a); //$c==10$a=1;$b=&$a;$c=(++$a); //$c==2$a=1;$b=&$a;$c=( ++$a)+(++$a); //$c==6$a=1;$b=&$a;$c=(++$a)+ in php7 (++$a)+(++$a);The result $c is 9.

In PHP, I post a form to a specified page. I want to receive the page and return the results simultaneously. How should I do this?

In PHP, I post a form to a specified page and want to receive the results from the page simultaneously. What should I do? <?php $form=” “; echo “”; That’s probably it! ! ! ! ! Now I want to receive the return result of “specified url” synchronously. How to achieve this? Looking for expert guidance,,,,,, guidance ?> ——Solution– ——————It’s too vague. Is it just Ajax scheduled submission? ——Solution——————–No I understand very well what you mean by “returning the result after receiving the “specified url””. Do you mean the server side or the browser side? I guess you want to submit the form across domains, which is not allowed! ——Solution——————–You This is a cross-domain submission, which the browser does not allow. You can only use PHP to request baidu.com on the server. The problem that comes with it is that Baidu will think you are a robot if you visit frequently, so this is difficult to do. ——Solution——————–Me I think you are talking about curl. Go check out the usage. ——Solution——————–If If you don’t know ajax, ajax should be able to solve your problem. ——Solution——————–Use frame ——Solution——————–If Specify the URL. If you have a page to process such a request,…

In PHP, the key value is sealed and the value is set to 0. Nested arrays are available.

In PHP, the key value is retained and the value is set to 0. Nested arrays can be used Implement a function that sets all elements in the PHP array to 0, using recursion public function setArraytoZero(&$array) { foreach ($array as &$value){ if(is_array($value)) { $this->setArraytoZero($value); } else { $value = 0; } } }

In PHP, I post a form to a specified page. I want to receive the page and return the results simultaneously. How should I do this?

In PHP, I post a form to a specified page and want to receive the results from the page simultaneously. What should I do? <?php $form=” “; echo “”; That’s probably it! ! ! ! ! Now I want to receive the return result of “specified url” synchronously. How to achieve this? Looking for expert guidance,,,,,, guidance ?> ——Solution– ——————It’s too vague. Is it just Ajax scheduled submission? ——Solution——————–No I understand very well what you mean by “returning the result after receiving the “specified url””. Do you mean the server side or the browser side? I guess you want to submit the form across domains, which is not allowed! ——Solution——————–You This is a cross-domain submission, which the browser does not allow. You can only use PHP to request baidu.com on the server. The problem that comes with it is that Baidu will think you are a robot if you visit frequently, so this is difficult to do. ——Solution——————–Me I think you are talking about curl. Go check out the usage. ——Solution——————–If If you don’t know ajax, ajax should be able to solve your problem. ——Solution——————–Use Framework——Solution——————– If you specify a URL and have a page to process such a request,…

In PHP, one file calls another file class, and then the output is garbled. Solution

In PHP, a file calls a method of another file class, and then the output is garbled. Please solve it! tt.php file <?phpclass CTest{ private $m_str; public function SetData($data) { $m_str=$data; } public function GetData() { return $m_str; }} ?> File test.php <?php echo “Begin test “; // Normal display require_once ‘./tt.php’; $p=new CTest(); $p->SetData(“Could you get this data?”); $str=$p->GetData(); echo $str; // Cannot display normally?> ——Display test.php execution results in the browserBegin test 锘 Share to: More ——Solution——————– class CTest{ private $m_str; public function SetData($data) { $this->m_str= $data; } public function GetData() { return $this->m_str; }} ——Solution——————–Please check Whether the encoding of $data is consistent with the page encoding. ——Solution——————–Set up the page encoding

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索