The dump function of thinkphp does not output the instance code. thinkphpdump
Dump function of Thinkphp
/*** Browser-friendly variable output * @ param mixed $ var variable * @ param boolean $ echo: whether the output is True by default. If it is false, the output string * @ param string $ label is returned. the tag is blank by default * @ param boolean $ strict. The default value is true * @ return void | string */function dump ($ var, $ echo = true, $ label = null, $ strict = true) {$ label = (null = $ label )? '': Rtrim ($ label).''; if (! $ Strict) {if (ini_get ('html _ errors ') {$ output = print_r ($ var, true); $ output =' <pre> '. $ label. htmlspecialchars ($ output, ENT_QUOTES ). '</pre>';} else {$ output = $ label. print_r ($ var, true) ;}} else {ob_start (); var_dump ($ var); $ output = ob_get_clean (); if (! Extension_loaded ('xdebug') {$ output = preg_replace ('/\] \=\> \ n (\ s +)/m','] => ', $ output); $ output = '<pre> '. $ label. htmlspecialchars ($ output, ENT_QUOTES ). '</pre>' ;}}if ($ echo) {echo ($ output); return null ;}else {return $ output ;}}
Test code
$ A = 'Chinese'; $ a = iconv ("UTF-8", "GB2312", $ a); dump ($ a); echo "
Test Results
It is found that only var_dump has output, while dump has no output.
Error analysis, locate htmlspecialchars
Trace the debugging function to check the htmlspecialchars function.
Official Website Description: Prior to version 5.4, the default encoding of this function is ISO-8859-1, 5.4 and 5.5 default encoding is UTF-8, after 5.6 is used as the default encoding configuration. P>
PHP Version 5.6.21, The htmlspecialchars encoding is the encoding of the configuration item, as follows:
Htmlspecialchars uses UTF-8 encoding, for gbk, gb2312 and other Chinese encoded strings, there is no output. No output is provided if the string of the htmlspecialchars function parameter contains a gbk or gb2312 encoded character. The test is as follows:
$ B = 'Chinese abc'; $ a = iconv ("UTF-8", "GB2312", $ B); $ c = $ B. $ a; var_dump (htmlspecialchars ($ a, ENT_QUOTES); // No output var_dump (htmlspecialchars ($ B, ENT_QUOTES); // The output is var_dump (htmlspecialchars ($ c, ENT_QUOTES); // No output
Solution
$ B = 'Chinese abc'; $ a = iconv ("UTF-8", "GB2312", $ B); $ c = $ B. $ a; var_dump (htmlspecialchars ($ a, ENT_QUOTES, 'iso-8859-1 '); // output, gb2312 encoding Chinese garbled var_dump (htmlspecialchars ($ B, ENT_QUOTES, 'iso-8859-1 '); // The output is var_dump (htmlspecialchars ($ c, ENT_QUOTES, 'iso-8859-1'); // The output is displayed, and the gb2312 encoding is garbled.
So add the htmlspecialchars function in the dump function of Thinkphp to the default encoding ISO-8859-1.
The above thinkphp dump function has no output instance code, which is all the content that I have shared with you. I hope to give you a reference and support for the customer's house.