Php writes a piece of code to change the variable value. If 3rd variables are not used, the values of $ a and $ B are exchanged, and the initial values of $ a and $ B are set ., This Baidu is a lot .... These two numbers must be integer numbers ..., a = a + bb = a-ba = a-B, PHPcode $ a = & quot; abcd & q php implement variable change value
Write a piece of code in PHP. If no 3rd variables are used, the values of $ a and $ B are exchanged, and the initial values of $ a and $ B are set.
------ Solution --------------------
This Baidu is a lot ....
These two numbers must be integer numbers...
------ Solution --------------------
A = a + B
B = a-B
A = a-B
------ Solution --------------------
PHP code
$ A = "abcd"; $ B = "1234"; echo "initialization a = $ a, B = $ B
"; $ A = $. $ B; $ B = strlen ($ B); $ B = substr ($ a, 0, (strlen ($ a)-$ B )); $ a = substr ($ a, strlen ($ B); echo "after switching a = $ a, B = $ B
";
------ Solution --------------------
Php already provides an excellent way
$ A = "abcd ";
$ B = "1234 ";
List ($ B, $ a) = array ($ a, $ B );
Echo "$ a $ B"; // 1234 abcd