函数

<?php

function swapStrings(string &$s1, string &$s2) {
    $temp = $s2;
    $s2 = $s1;
    $s1 = $temp;
}

$s1 = "A";
$s2 = "B";
swapStrings($s1, $s2);
//s1 is "B", s2 is "A"

echo "s1 is $s1, s2 is $s2";