1.用list()
$a = 10;
$b = 25;
list($a,$b)=array($b,$a);
echo $a.'/'.$b;//25/10
2.用传值方式加&符
function swap(&$a,&$b){
$c = '';
$c = $a;
$a = $b;
$b = $c;
}
$a = 25;
$b = 35;
swap($a,$b);
echo $a.'/'.$b;
方法三:使用数组分割
$a = "123";
$b = "456";
$b = $a."#$".$b;
$b = explode("#$",$b);
$a = $b[1];
$b = $b[0];
echo $a."-".$b;
方法四:使用异或运算
$a = "fsdfds";
$b = "xiaorui";
$a = $a^$b;
$b = $b^$a;
$a = $a^$b;
echo $a."-".$b;