3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test_case($a, $b, $c) { // Without Parenthesis if ($a || $b && $c) { $test1 = TRUE; } else { $test1 = FALSE; } // With Parenthesis if (($a || $b) && $c) { $test2 = TRUE; } else { $test2 = FALSE; } // Compare result if ($test1 !== $test2) { printf( 'Condition (%s || %s && %s) does NOT match ((%s || %s) && %s) --- Should have been "%s" but was actually "%s"'.PHP_EOL, strtoupper(var_export($a, TRUE)), strtoupper(var_export($b, TRUE)), strtoupper(var_export($c, TRUE)), strtoupper(var_export($a, TRUE)), strtoupper(var_export($b, TRUE)), strtoupper(var_export($c, TRUE)), strtoupper(var_export($test2, TRUE)), strtoupper(var_export($test1, TRUE)) ); } else { printf( 'Condition (%s || %s && %s) works as intended'.PHP_EOL, strtoupper(var_export($a, TRUE)), strtoupper(var_export($b, TRUE)), strtoupper(var_export($c, TRUE)) ); } } // Test all possible variations test_case(TRUE, TRUE, TRUE); test_case(TRUE, TRUE, FALSE); test_case(TRUE, FALSE, TRUE); test_case(TRUE, FALSE, FALSE); test_case(FALSE, TRUE, TRUE); test_case(FALSE, TRUE, FALSE); test_case(FALSE, FALSE, TRUE); test_case(FALSE, FALSE, FALSE);
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
Condition (TRUE || TRUE && TRUE) works as intended Condition (TRUE || TRUE && FALSE) does NOT match ((TRUE || TRUE) && FALSE) --- Should have been "FALSE" but was actually "TRUE" Condition (TRUE || FALSE && TRUE) works as intended Condition (TRUE || FALSE && FALSE) does NOT match ((TRUE || FALSE) && FALSE) --- Should have been "FALSE" but was actually "TRUE" Condition (FALSE || TRUE && TRUE) works as intended Condition (FALSE || TRUE && FALSE) works as intended Condition (FALSE || FALSE && TRUE) works as intended Condition (FALSE || FALSE && FALSE) works as intended
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
159.24 ms | 408 KiB | 5 Q