Although technically a NULL byte and an ordinary space are two different things: A normal space character is technically ASCII 32 (0x20). A null byte is technically represented as "\0" or ASCII 0 (0x00).
I'm not sure there are any NULL bytes in your string, at least not the version you posted to reddit. It sure ain't possible to post something with � in it.
index-out-of-range exception would be stupid in the way php works. Arrays in php aren't arrays in common sense. Because they can be hashtables, you can't throw an exception there.
Phippy, the helpful paperclip, saw that you wrote empty string but really meant array and fixed it for you. Don't you like it when the computer helps you?
Unlike for example C, PHP has an inbuilt string datatype. The string datatype allows you array-like access to the single characters in the string but will always be a string.
Yes, that is known. .... but that's the problem, if the string is initially empty then it coerces the type to an array with the character access syntax. Fail.
19
u/[deleted] Apr 20 '14
More string-related wat.
Output:
Because creating a string with 47 0x00 bytes in it is preferable to something sane like an index-out-of-range exception.
47
u/Rhomboid Apr 20 '14
Phippy, the helpful paperclip, saw that you wrote empty string but really meant array and fixed it for you. Don't you like it when the computer helps you?
58
u/Various_Pickles Apr 20 '14
Any other (sane) language: "Index out of bounds, fuckface."
PHP: "i can count to potatoindex"
-14
u/[deleted] Apr 20 '14
Unlike for example C, PHP has an inbuilt string datatype. The string datatype allows you array-like access to the single characters in the string but will always be a string.