Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- assign japanese string to var
March 17, 2005, 7:05 am
rate this thread
Following code contains japanese string that is assigned to variable
$str = "$B%0%C%I%P%$%T%+%=(B";
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%+%=(B) to
variable without error.
Re: assign japanese string to var
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