3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Products { public static function sortByPriceAscending($jsonString) { $info = json_decode($jsonString, true); usort($array, "cmp"); print_r($info); } public function cmp($a, $b) { return strcmp($a["price"], $b["price"]); } } // For testing purposes (do not submit uncommented) echo Products::sortByPriceAscending('[{"name":"eggs","price":1},{"name":"coffee","price":9.99},{"name":"rice","price":4.04}]');
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: usort(): Argument #1 ($array) must be of type array, null given in /in/41VT5:7 Stack trace: #0 /in/41VT5(7): usort(NULL, 'cmp') #1 /in/41VT5(22): Products::sortByPriceAscending('[{"name":"eggs"...') #2 {main} thrown in /in/41VT5 on line 7
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:
28.79 ms | 406 KiB | 5 Q