bh******@indiatimes.com wrote:
Following code contains japanese string that is assigned to variable
$str.
code
=============
<?php
$str = "$B%0%C%I%P%$%T%+%=(J";
?>
=========
When i am executing above program it gives me error as following.
Parse error: parse error, unexpected $ in
/var/www/html/bhavin/mohla1.2.2/b.php on line 3
Do anybody have solution for the above problem.
How can i assign above japanese string($B%0%C%I%P%$%T%+%=(J) to
variable without error.
You're using Shift-JIS encoding, aren't you?
Don't. Use EUC-JP instead.
You're getting problems because the last character ("$B%=(J") encodes as
[&?131;] + [backslash] in shift-JIS encoding. PHP sees the backslash and
escapes your closing quite mark, so the rest of your PHP script is getting
swallowed up by the string. There are lots of other Shift-JIS characters
that cause the same problem.
In EUC-JP encoding, Japanese characters are all encoded with byte codes in
the range 161-255 (or thereabouts), so this problem never happens.
--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.et/phil.ronan/