Question:What will the following script output?<?php
function sort_my_array ($array){
return sort ($array);
}
$a1 = array (3, 2, 1);
var_dump (sort_my_array (&$a1));
?>
A NULL
B 0 => 1, 1 => 2, 2 => 3
C An invalid reference error
D 2 => 1, 1 => 2, 0 => 3
E bool (true)
+ ExplanationThe correct answer is E. The sort function works directly on the array passed (by reference) to it, without creating a copy and returning it. Instead, it returns the Boolean value True to indicate a successful sorting operation (or False to indicate an error). Note that this example passes the $a1 array to sort_my_array() by reference; this technique is deprecated and the function should be re-declared as accepting values by reference instead.