I am currently experimenting around and getting to know how PHP handles input file encoding.
When the following code is stored in a UTF-8 file, PHP correctly executes the code making the desired output:
<?php
echo 10;
Output:
10
However, when the same file is converted into UTF-16 (LE), PHP doesn't execute the code. Instead, when I run the file, I get the following output:
<?php
echo 10;
I already know that when PHP determines that a given segment in a file doesn't represent PHP code, it just echoes it all as it is. That is clear to me.
But what isn't clear to me is that why is PHP not able to parse the UTF-16 file correctly?
Is the PHP engine only meant to work with an encoding that's ASCII-compatible? I can't find any resource that actually specifies the encoding used by the PHP engine in order to parse a given PHP file. I believe that because the parser is coded in C, the ASCII charset is used, but still a formal description would be desirable.