3v4l.org

run code in 300+ PHP versions simultaneously
<?php $values = [ #ints 0,1,2,-1,-2, #floats 0.0,0.1,0.2,1.0,1.1,2.0,2.1, -0.1,-0.2,-1.0,-1.1,-2.0,-2.1, #strings "", "a", "0","@","NULL", #bool true, false, #array [], ["a"],[[]], #object new stdClass, #null NULL,"\0", function(){}, ]; foreach($values as $k => $v){ if(is_scalar($v)){ $j = new stdClass; $j->p = $v; $test[] = $j; } } foreach($values as $k => $v){ echo (string) $v ?: "fail - $v", "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
fail - 0 1 2 -1 -2 fail - 0 0.1 0.2 1 1.1 2 2.1 -0.1 -0.2 -1 -1.1 -2 -2.1 fail - a fail - 0 @ NULL 1 fail - Warning: Array to string conversion in /in/gUPrp on line 31 Array Warning: Array to string conversion in /in/gUPrp on line 31 Array Warning: Array to string conversion in /in/gUPrp on line 31 Array Fatal error: Uncaught Error: Object of class stdClass could not be converted to string in /in/gUPrp:31 Stack trace: #0 {main} thrown in /in/gUPrp on line 31
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:
74.45 ms | 402 KiB | 8 Q