echo '<a title=' .json_encode("按时间先后进行排序") . '>test</a>';
The above will generate something like "\u6309\u65f6\u95f4\u5148\u540e\u8fdb\u884c\u6392\u5e8f" and it's a mess!
echo '<a title=' .json_encode("按时间先后进行排序") . '>test</a>';
The above will generate something like "\u6309\u65f6\u95f4\u5148\u540e\u8fdb\u884c\u6392\u5e8f" and it's a mess!
No, that’s JSON. JSON encoders are free to copy characters as-is (except for doublequote, backslash, or control characters) or to encode them using the \uxxxx
notation. So even while the above is not beautiful, it’s valid JSON and will ensure that the string will be decoded correctly.
have you tried this: http://us.php.net/manual/en/function.json-encode.php#74878
The title
attribute value is not treated as JavaScript. Use json_encode
only for converting a PHP type into a JavaScript/JSON expression.
Try this instead:
echo '<a title="按时间先后进行排序">test</a>';
But you would need to send your document with the the same encoding as your title text.