Re: php seems to be inconsistent in its handling of backslashes ... maybe?

From: Date: Sun, 22 Apr 2007 10:41:54 +0000
Subject: Re: php seems to be inconsistent in its handling of backslashes ... maybe?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-253483@lists.php.net to get a copy of this message
Richard Lynch wrote:
<?php preg_match('#\\#','any-string'); => warning
This seemed strange: warnings with 2 and 6 backlashes
For 2 backslashes, PHP "ate" the 2 backslashes, and handed PCRE #\#, and PCRE does not like that at all.
Yet preg_match('#\\#','any-string'); does *not* throw a warning when I run the 2nd script - the one where I call it in the loop.
no warnings with 3, 7 warning with 5 but not with 3 and 7.
PHP and PCRE are doing their damndest to make sense of the garbage you typed, but if you type garbage, you get garbage. http://us.php.net/manual/en/language.types.string.php
But PHP doesn't appear to be consistent. In the 2nd script, I *do* get warnings with 3 and 7 slashes. PHP can't be inconsistent. So there must be some semantic difference in my 2 scripts which unfortunately is eluding me. Cheers

« previous php.general (#253483) next »