Echo and Var_dump's core function is no different, are "output variable value", but echo biased to the product, to the customer, debugging staff, programmers more suitable to use var_dump to output variables, in debugging, say goodbye to the hard-to-use echo!
Echo can only output the value of a variable, and var_dump can output both the value and the type of the variable.
If you do not do any processing, in PHP is not directly output an array, need to use a for loop can, if directly with echo output an array, PHP will error, but Var_dump is can, but also the output is very perfect, no need to pass any processing.
Then there is the output of the class variable, if no processing, ECHO will also be error, var_dump can be easily output.
An example also illustrates the problem with the following code:
";//gorgeous delimiter, please ignore var_dump ($i); echo"
";///gorgeous delimiter, ignore//For the output of the array ($arr=array); echo $arr;//Output Warning echo"
";//gorgeous delimiter, please ignore var_dump ($arr); echo"
";///gorgeous delimiter, ignore//for Class output class test{public $i =" I ";p ublic $j =" J ";} $test = new test (); Var_dump ($test); echo "
";///Gorgeous delimiter, please ignore echo $test;//Output error echo"
";//gorgeous delimiter, please ignore?>
The output results are as follows:
Can see var_dump for variables, arrays, classes of output, has a good performance, through Var_dump can easily observe the variables, arrays, classes at this time the value of how much. and Echo is an error to the dog, of course, in the output of ordinary Web pages, we do not want software products customers see Var_dump output information, so echo is the most basic thing.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above describes the echo and var_dump, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.