I'm trying to get zend engine to interpret my PHP scripts as UTF-16BE. On a PHP 5.4 setup, I have the following settings in my PHP.ini file:
zend.script_encoding = UTF-16BE
zend.detect-unicode = 0
zend.multibyte = On
This is my script index.php:
<?php echo '1';
The file is a total of 32 bytes, saved using UTF-16BE:
FE FF // BOM
00 3C 00 3F 00 70 00 68 00 70 00 20 // <?php
00 65 00 63 00 68 00 6F 00 20 // echo
00 27 00 31 00 27 // '1'
00 3B // ;
However the script is not working; the output is <?php echo '1';
instead of 1
.
So I tried removing the BOM:
00 3C 00 3F 00 70 00 68 00 70 00 20 // <?php
00 65 00 63 00 68 00 6F 00 20 // echo
00 27 00 31 00 27 // '1'
00 3B // ;
But the output is still <?php echo '1';
instead of 1
.
Then I tried encoding the start sequence — <?php
— in ASCII, while the remaining characters remain UTF-16BE encoded:
3C 3F 70 68 70 20 // <?php
00 65 00 63 00 68 00 6F 00 20 // echo
00 27 00 31 00 27 // '1'
00 3B // ;
The engine seems to be able to interpret the PHP script now, but it's still not working:
Warning: Unexpected character in input: ' in C:\xampp\htdocs\test\index.php on line 1
Warning: Unexpected character in input: ' in C:\xampp\htdocs\test\index.php on line 1
Parse error: syntax error, unexpected 'c' (T_STRING) in C:\xampp\htdocs\test\index.php on line 1
How does zend.script_encoding
work?
How can we get the engine to interpret scripts written in a specific encoding?