preg_quote() and the
# Character
The preg_quote() function is used to prefix every
character of a string that is part of the regular expression syntax
with a \ character. Prior to PHP 7.3, the
# character was not prefixed with a \
character.
var_dump(preg_quote('.\+*?[^]$(){}=!<>|:-#'));
Executing the code shown above with PHP 7.3 and newer will print the output shown below:
string(42) "\.\\\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:\-\#"
Executing the code shown above with PHP 7.2 and older printed the output shown below:
string(42) "\.\\\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:\-#"