1, for the number $ A = $a + $b; $b = $a-$b; $a = $a-$b;//2, using list structure $ A = ' a '; $b = ' B '; Var_dump ($a, $b); list ($a, $b) = Array ($b, $a); Var_du MP ($a, $b);//3, using array $ A = ' a ', $b = ' B '; Var_dump ($a, $b); $a = array ($a, $b); $b = $a [0]; $a = $a [1];var_dump ($a, $b);//4, replace $ with string A = ' a '; $b = ' B '; Var_dump ($a, $b); $a. = $b; $b = Str_replace ($b, ' ', $a); $a = Str_replace ($b, "', $a); Var_dump ($a, $b);//5, make Use a string to intercept $ A = ' AA '; $b = ' BB '; var_dump ($a, $b); $a. = $b; $b = substr ($a, 0, strlen ($b)); $a = substr ($a, strlen ($b)); Var_dump ($a, $b);//6, using explode$a = ' AA '; $b = ' BB '; var_dump ($a, $b); $a. = ' @@ '. $b; $a = explode (' @@ ', $a); $b = $a [0]; $a = $a [1];var_dump ( $a, $b);//7, using XOR $ A = ' AA '; $b = ' BB '; var_dump ($a, $b); $a = $a ^ $b; $b = $b ^ $a; $a = $a ^ $b; Var_dump ($a, $b);
The above describes the PHP variable exchange, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.