PHP Jsonp single quote escape, JSONP quote escape
PHP JSONP output is generally in the following format:
Callbackname (' JSON string ');
If the middle JSON string contains single quotes, this output is problematic and the caller is generally unable to handle it, so we want to escape the single quotes.
If it is generated in Json_encode mode, it can be escaped in the following way:
$ret = Json_encode ($result, json_hex_apos); Header (' Content-type:text/javascript; Charset=utf-8 '); Echo $callback $ret . '\');';
Here Json_hex_apos is PHP is provided to the single quote to \u0027.
If it is a string concatenation, you can use the following method:
$jsonData Preg_replace $jsonData);
and then output.
http://www.bkjia.com/PHPjc/916030.html www.bkjia.com true http://www.bkjia.com/PHPjc/916030.html techarticle PHP jsonp Single-quote escape, Jsonp quotes escaping PHP JSONP output is generally in the following format: Callbackname (' JSON string '), if the intermediate JSON string contains single quotes, this output is ...