On Mon, 2007-04-23 at 08:36 -0500, Philip Thompson wrote: > On Apr 22, 2007, at 1:29 AM, Richard Lynch wrote: > > > On Sun, April 22, 2007 12:54 am, ufan100@xxxxxxxxx wrote: > >> -- or maybe it's just the PCRE extension > >> -- or quite likely I have got something wrong > >> > >> Hello members, > >> I'm hoping you could enlighten me. > >> > >> Using error_reporting = E_ALL | E_STRICT, I tested the > >> following statements: > > > > PHP interprets \\ inside of '' to turn \\ into \ > > > > It also tries to be halfway smart about mistakes with \ followed by > > some other non-special character, by just pretending you knew what you > > were doing and had \\ there to get just one \, even though you didn't. > > Not that I can deny Richard's infinite knowledge of PHP (and it > *eating* code), but is it PHP's responsibility to determine what the > user has typed is (in)correct AND try to *fix* it? Shouldn't PHP just > assume the programmer is not a complete idiot? If there's an error/ > warning/etc, throw it but don't correct it. > > My $.02. Feel free to set me straight - I'm always up for learning. It doesn't try to "fix" the code, it is just a somewhat odd case of escaping. Singled quoted strings accept backslashes in two ways, either escaped with a backslash or without an escaping backslash. Both of the following are valid and produce the same string: echo 'Foo \ fee!'."\n"; echo 'Foo \\ fee!'."\n"; A problem in user expectation often arises when you have a backslash preceding a single quote. For instance: echo 'Foo \' fee!'."\n"; But this doesn't give you the backslash since the backslash is used to escape the quote... and so the next step is usually to try: echo 'Foo \\' fee!'."\n"; But now the backslash is escaped and not the quote so we need: echo 'Foo \\\' fee!'."\n"; Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php