Codice PHP:
function cmp($a$b)
{
    if (
$a == $b) {
        return 
"$a - $b";
    }
    return (
$a $b) ? "$a - $b"$b - $a";
}


$str1 'casa';
$str2 'bosco';

echo 
cmp($str1,$str2);