3v4l.org

run code in 300+ PHP versions simultaneously
<?php $products = array(); class Products { public $chemID; public $catID; } $prod1 = new Products; $prod1->chemID=1; $prod1->catID=1; array_push($products,$prod1); for($i = 1; $i < 5; $i++) { ${'prod'.$i} = new Products; ${'prod'.$i}->chemID = $i; ${'prod'.$i}->catID = $i; array_push($products,${'prod'.$i}); } $carts = (object)array(array("chemID"=> 1, "catID" => 4),array("chemID"=> 2, "catID" => 4), array("chemID"=> 1, "catID" => 1)); var_dump($products); foreach($products as $key=>$value) { echo $value; }
Output for git.master, git.master_jit, rfc.property-hooks
array(5) { [0]=> object(Products)#1 (2) { ["chemID"]=> int(1) ["catID"]=> int(1) } [1]=> object(Products)#2 (2) { ["chemID"]=> int(1) ["catID"]=> int(1) } [2]=> object(Products)#3 (2) { ["chemID"]=> int(2) ["catID"]=> int(2) } [3]=> object(Products)#4 (2) { ["chemID"]=> int(3) ["catID"]=> int(3) } [4]=> object(Products)#5 (2) { ["chemID"]=> int(4) ["catID"]=> int(4) } } Fatal error: Uncaught Error: Object of class Products could not be converted to string in /in/qYKOY:21 Stack trace: #0 {main} thrown in /in/qYKOY on line 21
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:
57.77 ms | 402 KiB | 8 Q