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

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

 



On Mon, April 23, 2007 8:36 am, 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.

The actual documented feature is that \ followed by anything other
than the characters defined to be special (another \, n, t, r various
hex and octal codes) just turns into a plain old \

To *ME* that means you *SHOULD* have had \\ there, since \ is the
escape character you use to get a \ inside of a string.

I've seen too many people go from:

"This is \best"

to

"This ia a \test"

and they do NOT understand why the heck \b and \t didn't work the same...


I'd be ecstatic if PHP gave a syntax error for a stray \ inside a
string, personally, but apparently I'm in the minority.

\\ is one of my regular rants, so you'll be hearing this again :-)

-- 
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


[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