3v4l.org

run code in 300+ PHP versions simultaneously
<?php // // () [] {} <> // // when not using them in the expression itself echo '(123) ', preg_match('(123)', "123"), "\n"; // when using them balanced echo '[[123]] ', preg_match('[[123]]', "1"), "\n"; // when using them unbalanced: <> which is rarely special echo '<1 < 2> ', preg_match('<1 < 2>', "1 < 2"), "\n"; // warning // must be escaped echo '<1 \< 2> ', preg_match('<1 \< 2>', "1 < 2"), "\n\n"; // when using them unbalanced: {} which is almost always special echo '{function [({]} ', preg_match('{function [({]}', "function () {"), "\n"; // warning // must be escaped even when it represents a literal character echo '{function [(\{]} ', preg_match('{function [(\{]}', "function () {"), "\n\n"; // // other plain symbols // echo '!1! ', preg_match('!1!', "1"), "\n"; echo '%1% ', preg_match('%1%', "1"), "\n"; echo '_1_ ', preg_match('_1_', "1"), "\n"; // // other symbols that can be special: # $ ^ * + | . ? // these will break your expression // echo '^^123$^ ', preg_match('^^123$^', "123"), "\n"; // warning echo '^\^123$^ ', preg_match('^\^123$^', "123"), "\n\n"; // no match (would match '^123' at the end of the string) echo '|(foo|bar|baz)| ', preg_match('|(foo|bar|baz)|', "foo"), "\n"; // warning echo '|(foo\|bar\|baz)| ', preg_match('|(foo\|bar\|baz)|', "foo"), "\n\n"; // no match (would match 'foo|bar|baz') // // beware: even - ' can be special // // - for a character set range echo '-[a-zA-Z]- ', preg_match('-[a-zA-Z]-', "m"), "\n"; // warning echo '-[a\-zA\-Z]- ', preg_match('-[a\-zA\-Z]-', "m"), "\n\n"; // no match (would match 'a' '-' 'z' 'A' 'Z') // ' for named subpatterns echo "'(?'alpha'[a-zA-Z])\k'alpha'' ", preg_match("'(?'alpha'[a-zA-Z])\k'alpha''", "mm"), "\n"; // warning about delimiter echo "'(?\'alpha\'[a-zA-Z])\k\'alpha\'' ", preg_match("'(?\'alpha\'[a-zA-Z])\k\'alpha\''", "mm"), "\n\n"; // warning about syntax
Output for git.master, git.master_jit, rfc.property-hooks
(123) 1 [[123]] 1 <1 < 2> Warning: preg_match(): No ending matching delimiter '>' found in /in/7IgoG on line 14 <1 \< 2> 1 {function [({]} Warning: preg_match(): No ending matching delimiter '}' found in /in/7IgoG on line 19 {function [(\{]} 1 !1! 1 %1% 1 _1_ 1 ^^123$^ Warning: preg_match(): Unknown modifier '1' in /in/7IgoG on line 36 ^\^123$^ 0 |(foo|bar|baz)| Warning: preg_match(): Unknown modifier 'b' in /in/7IgoG on line 39 |(foo\|bar\|baz)| 0 -[a-zA-Z]- Warning: preg_match(): Unknown modifier 'z' in /in/7IgoG on line 47 -[a\-zA\-Z]- 0 '(?'alpha'[a-zA-Z])\k'alpha'' Warning: preg_match(): Unknown modifier 'a' in /in/7IgoG on line 51 '(?\'alpha\'[a-zA-Z])\k\'alpha\'' Warning: preg_match(): Compilation failed: unrecognized character after (? or (?- at offset 2 in /in/7IgoG on line 52

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:
43.82 ms | 403 KiB | 8 Q