Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
February 8, 2007, 7:03 am
rate this thread
backslash before every character listed in the character list. I've
done a couple of experiments:
echo bin2hex(addcslashes("a","a")) gives 5c31, as expected (''
followed by 'a')
Next, I tried
echo bin2hex(addcslashes("","")); which gave 5c 30 30 30, which is
a backslash followed by 3 spaces. What's happening here? I would have
thought that the output would be
5c 00 (backslash followed by a null)
Meh, I re-read the manual more closely and realised that: "while other
non-alphanumeric characters with ASCII codes lower than 32 and higher
than 126 converted to octal representation."
so 5c 30 30 30 = \ octal representation of 0
or, if the byte x01 was escaped, the result would be
5c 30 30 31 = 1 = \ octal representation of 01
What is the point of converting to an octal representation? Where
would it be used? I've never heard of this being used in the c
Ascii lowercase 'a' is 0x61, not 0x31. 0x31 is '1'. 0x5c is indeed a
backslash. I got 61 when I tried the line above.
0x30 is ascii '0' (zero), not a space (which is 0x20).
Something quite odd. Since is the string terminating character, it would
seem that it throws the functions a bit off. File a bug report?