It turns out that parsing a double quoted strings is a real challenge. An backslash is recognized differently depending on the context it is used in. I found this out when I tried to correctly parse the following string:
"Octal: \123"In PHP this will be evaluated to
"Octal: S"So the "\123" part should be parsed as a separate part. However, if it says "\1234" it is just a part of the string since octal characters can only be encoded by three digits.
Another example is that of the advanced string parsing features. Examine the following strings
$foo = "Hello {$name}";In the variable $foo, the brackets are discarded and the variable $name is expanded. The variable $bar just contains the exact same string as stated above, including the brackets and the dollar sign.
$bar = "Hello { $name}";
These examples are a nightmare from the parsing point of view. So I will let this rest for now and move on to the statements of PHP in the following session. This should keep me from throwing my screen out of the window because of frustration.
No comments:
Post a Comment