3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Products { public $barrels; } $products = array(); for($i = 0; $i < 5; $i++) { ${'prod'.$i} = new Products; ${'prod'.$i}->barrels->chemID = $i; ${'prod'.$i}->barrels->catID = $i; array_push($products,${'prod'.$i}); } var_dump($products); class Carts { public $chemID; public $catID; } $carts = array(); for($i = 0; $i < 5; $i++) { ${'cart'.$i} = new Carts; ${'cart'.$i}->chemID = ($i % 2 == 0 ? $i : $i + 2); ${'cart'.$i}->catID = ($i % 2 == 0 ? $i : $i + 3); array_push($carts,${'cart'.$i}); } var_dump($carts); $cnt = 0; foreach($products as $pkey=>$pobj) { foreach($carts as $ckey=>$cobj) { if($cobj->chemID == $pobj->barrels->chemID && $cobj->catID == $pobj->barrels->catID) { $cnt++; } } } echo 'Count of matches: ' . $cnt;
Output for rfc.property-hooks
Fatal error: Uncaught Error: Attempt to assign property "chemID" on null in /in/uXFIq:10 Stack trace: #0 {main} thrown in /in/uXFIq on line 10
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:
51.17 ms | 1703 KiB | 4 Q