3v4l.org

run code in 300+ PHP versions simultaneously
<?php $bads = [ '+11', '- 68', '[img', '$cool ', '# hash' ]; $tests = []; foreach ($bads as $bad) { $tests["A $bad B"] = true; $tests["$bad"] = true; $tests["A $bad"] = true; $tests["$bad B"] = true; $tests["x${bad}x"] = false; $tests["x${bad}"] = false; $tests["${bad}x"] = false; } foreach ($tests as $string => $expected) { $expect = (int)$expected; $actual = (int)contains($string, $bads); if ($actual !== $expect) { echo "FAIL: '$string' should be $expect, is $actual"; } else { echo "PASS: '$string' was expected $expect"; } echo PHP_EOL; } #### FUNCTION ### function contains($str, $bads) { $template = '/(\s+%1$s\s+|^\s*%1$s\s+|\s+%1$s\s*$|^\s*%1$s\s*$)/'; foreach ($bads as $a) { $regex = sprintf($template, preg_quote($a, '/')); if ($x = preg_match($regex, $str, $matches)) { return true; } } return false; }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /in/RH6r3 on line 11 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /in/RH6r3 on line 12 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /in/RH6r3 on line 13 PASS: 'A +11 B' was expected 1 PASS: '+11' was expected 1 PASS: 'A +11' was expected 1 PASS: '+11 B' was expected 1 PASS: 'x+11x' was expected 0 PASS: 'x+11' was expected 0 PASS: '+11x' was expected 0 PASS: 'A - 68 B' was expected 1 PASS: '- 68' was expected 1 PASS: 'A - 68' was expected 1 PASS: '- 68 B' was expected 1 PASS: 'x- 68x' was expected 0 PASS: 'x- 68' was expected 0 PASS: '- 68x' was expected 0 PASS: 'A [img B' was expected 1 PASS: '[img' was expected 1 PASS: 'A [img' was expected 1 PASS: '[img B' was expected 1 PASS: 'x[imgx' was expected 0 PASS: 'x[img' was expected 0 PASS: '[imgx' was expected 0 PASS: 'A $cool B' was expected 1 PASS: '$cool ' was expected 1 PASS: 'A $cool ' was expected 1 PASS: '$cool B' was expected 1 PASS: 'x$cool x' was expected 0 PASS: 'x$cool ' was expected 0 PASS: '$cool x' was expected 0 PASS: 'A # hash B' was expected 1 PASS: '# hash' was expected 1 PASS: 'A # hash' was expected 1 PASS: '# hash B' was expected 1 PASS: 'x# hashx' was expected 0 PASS: 'x# hash' was expected 0 PASS: '# hashx' was expected 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:
27.46 ms | 409 KiB | 5 Q