paso los parametros como dices pero tampoco los imprime.
Código PHP:
<?php
$word1 = "casa";
$word2 = "ferrocarril";
$word3 = "xilofon";
//function
function wordSort($word1, $word2, $word3){
if ($word1 > $word2 && $word1 > $word3) {
if ($word2 > $word3) {
$result = "$word1 $word2 $word3";
} elseif ($word3 > $word2) {
$result = "$word1, $word2, $word3";
}
elseif ($word2 > $word1 && $word2 > $word3) {
if ($word1 > $word3) {
$result = "$word2, $word1, $word3";
} elseif ($word3 > $word1) {
$result = "$word2, $word3, $word1";
}
} elseif ($word3 > $word1 && $word3 > $word2) {
if ($word1 > $word2) {
$result = "$word3, $word1, $word2";
} elseif ($word2 > $word1) {
$result = "$word3, $word2, $word1";
}
}
}
return $result;
}
echo "Ordenadas alfabeticamente:".wordSort($word1, $word2,$word3);
?>