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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux