3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = 1; $b = 2; $c = 0; $d = $e = $f = -1; if ( $d = $c && $e = $b && $f = $a ) { echo "yes"; } var_dump($d, $e, $f); // Why isn't this a parse error?? It doesn't do: // $d = ($c && $e) = ($b && $f) = $a // (because that is a parse error on its own) // So what does it do?? echo "\n\n"; $d = $e = $f = -1; if ( $d = $c and $e = $b and $f = $a ) { echo "yes"; } var_dump($d, $e, $f); // ($d = $c) && ($e = $b) && ($f = $a) so only $d=$c is executed, bc $c is falsy echo "\n\n"; $d = $e = $f = -1; if ( $d = $a and $e = $b and $f = $c ) { echo "yes"; } var_dump($d, $e, $f); // ($d = $a) && ($e = $b) && ($f = $c) and all 3 are executed, bc first 2 are truthy
Output for git.master, git.master_jit, rfc.property-hooks
bool(false) int(-1) int(-1) int(0) int(-1) int(-1) int(1) int(2) int(0)

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:
26.03 ms | 405 KiB | 5 Q