On Sun, April 22, 2007 5:41 am, ufan100@xxxxxxxxx wrote: > 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. I confess I didn't really pay attention to the one in the loop, but I suspect that what you typed did not actually generate '#\\#' like you think it did... > PHP can't be inconsistent. So there must be some semantic > difference in my 2 scripts which unfortunately is eluding me. If you've already got a single backslash in a variable: $foo = '\\'; and then you do: $bar = "$foo$foo"; That is probably not the same at all as: $bar = "\\"; I would not expect, anyway, that $foo$foo will be considered by PHP string parser as something to be re-evaluated to detect escape characters co-mingled from two variables... If you were going to do that, you would want to keep re-re-re-parsing it -- After all, why stop at just TWO runs through? [shudder] So, no, I don't think your loop did the same thing as the literal \ charcters inside of "" marks... They're just not the same thing. That's kind of the whole point of this page: http://us.php.net/manual/en/language.types.string.php Quote marks (and apostrophes) are handled quite specially by the PHP parser. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php