3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ObjPrueba { var $nombre; var $age; function ObjPrueba($nombre, $age) { $this->nombre = $nombre; $this->age = age; } /* Ésta es la función de comparación estática: */ static function cmp_obj($a, $b) { $al = int($a->age); $bl = int($b->age); if ($al == $bl) { return 0; } return ($al > $bl) ? +1 : -1; } } $a[] = new ObjPrueba("c", 22); $a[] = new ObjPrueba("b", 15); $a[] = new ObjPrueba("d", 2); usort($a, array("ObjPrueba", "cmp_obj")); foreach ($a as $elemento) { echo $elemento->nombre ." -> ". $elemento->nombre. "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function int() in /in/9FRof:16 Stack trace: #0 [internal function]: ObjPrueba::cmp_obj(Object(ObjPrueba), Object(ObjPrueba)) #1 /in/9FRof(29): usort(Array, Array) #2 {main} thrown in /in/9FRof on line 16
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
55.86 ms | 401 KiB | 8 Q