In the process of program development; printing data for viewing debugging is very frequent; it is rather painful if there is no easy-to-read style;
Define an array first;
$array =array (' t0 ' = ' test0 ', ' t1 ' = ' test1 ', ' T3 ' =>array (' tt0 ' = ' test0 ', ' tt1 ' = ' tes ') T1 ', ' tt3 ' = ' test3 ',));
If the PHP system function Print_r Printing, the effect is this;
Print_r ($array);
650) this.width=650; "alt=" 1.jpg "src=" http://www.baijunyao.com/Upload/image/ueditor/20150506/1430843282444069. JPG "title=" 1430843282444069.jpg "/>
I think in addition to the super-divine level of eyesight, the average person is difficult to read;
Fortunately PHP has prepared a slightly more reliable var_dump function for us, the effect is this:
Var_dump ($array);
650) this.width=650; "alt=" 2.jpg "src=" http://www.baijunyao.com/Upload/image/ueditor/20150506/1430843535281302. JPG "title=" 1430843535281302.jpg "/>
Var_dump temporarily used to print fractional groups can also do well; If you print a complex structure, or long-term development of a project, this style still looks ugly;
So handwritten a P-function, the effect is such;
function P ($data) {echo '
650) this.width=650; "alt=" 3.jpg "src=" http://www.baijunyao.com/Upload/image/ueditor/20150506/1430843735232489. JPG "title=" 1430843735232489.jpg "/>
The world instantly clean and tidy, the reason is added 2
For a long time it was a primitive function, until one day it was discovered that Bootstrap's style definition of <pre>, so the P function was upgraded to look like this, and the effect was this:
function P ($data) {echo ' <pre style= ' display:block;padding:9.5px;margin:0px 0px 10px;font-size:13px;line-height: 1.42857; Color: #333; Word-break:break-all;word-wrap:break-word;background-color: #F5F5F5; border:1px solid #CCC; border-radius:4px; " > '. Print_r ($data, true). ' </pre> ';} P ($array);
650) this.width=650; "alt=" 4.jpg "src=" http://www.baijunyao.com/Upload/image/ueditor/20150506/1430843978898196. JPG "title=" 1430843978898196.jpg "/>
Again deeply thanked Bootstrap;
This article for Bai Jun Remote original article, reprinted without contact with me, but please specify from Bai Jun remote blog www.baijunyao.com
This article is from the "Bai Jun Remote Blog" blog, please be sure to keep this source http://shuaibai123.blog.51cto.com/10163353/1686253
Print PHP arrays in a way that fits human reading