} echo "<br/>"; } echo "<br/>"; // However, to sort, we need a comparator that takes two objects as // arguments, so as to work with the usort framework. Note the // somewhat odd syntax below. The second argument to the usort // function is actually an array with the class name and method name // as a pair. This is needed if the comparator is a method within // a class. usort($A, array('Animal', 'compare')); echo "Output in sorted order:<br/>"; foreach ($A as $animal) { echo "{$animal}<br/>"; } echo "<br/>"; usort($A, array('Animal', 'compareTwo')); echo "Output in sorted order:<br/>"; foreach ($A as $animal) { echo "{$animal}<br/>"; } echo "<br/>"; // We can call static methods using the scope resolution operator Animal::wacky(); // Objects are automatically destructed at the end of the script, so // uncommenting the line below will have no effect //unset($A); ?> </body> </html>