Re: php seems to be inconsistent in its handling of backslashes ... maybe?
| From: | ufan100 at gmail dot com | 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
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.This seemed strange: warnings with 2 and 6 backlashesFor 2 backslashes, PHP "ate" the 2 backslashes, and handed PCRE #\#, and PCRE does not like that at all.
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. Cheersno 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