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);

preferences:
43.34 ms | 406 KiB | 5 Q