Juan Pablo Romero wrote:
I've recently come across this warning.
As I understand it, it's when an invalid regular expression is given to the inbuilt function ereg() or eregi()
I got the warning when the following was
executed at run-time:
if (ereg("?", $url))
The problem seemed to go away when I
escaped the ? as follows:
if (ereg("\?", $url))
Further explanation
(This will be because the syntax of the ?
in regular expression is to say that the
character before it MIGHT be there. Since
there is no character before the question
mark, "?" is invalid as a regular
expression).
I'll quote from the helpful resource
http://www.phpbuilder.com/columns/dario19990616.php3
"In order to be taken literally, you must escape the characters ".[$()|*+?{\" with a backslash ('\'), as they have special meaning."
The article also points out:
- you may need to escape a character twice because some characters need to be escaped in a PHP string too!
- the case if different when characters are in [] square brackets.
See the article for more details - it's very good at explaining regular expressions!
Hope this helps someone :-)
Thop