[Php] the core functions of echo and var_dump echo are the same as those of var_dump. they are all "output variable values". however, echo tends to be a product, debugs and programmers are more suitable to use var_dump to output variables. when debugging, say goodbye to the echo that is difficult to use!
Echo can only output the value of a variable. var_dump can output the value and type of a variable at the same time.
If no processing is performed, an array cannot be directly output in php. a for loop is required. If an array is output using echo, php reports an error, however, var_dump is fine, and the output is perfect without any processing.
The other is the output of class variables. If no processing is done, echo will also report an error, and var_dump can easily output.
The code is as follows:
"; // Gorgeous separator, ignore var_dump ($ I); echo"
"; // Gorgeous separator, please ignore // For array output $ arr = array (, 3); echo $ arr; // output warning echo"
"; // Gorgeous Separator. ignore var_dump ($ arr); echo"
"; // Gorgeous separator, please ignore // For class Output class Test {public $ I =" I "; public $ j =" j ";} $ test = new Test (); var_dump ($ test); echo"
"; // Gorgeous separator, ignore echo $ test; // output the echo Error"
"; // Gorgeous separator, please ignore?>
The output result is as follows:
You can see that var_dump is very good for the output of variables, arrays, and classes. through var_dump, you can easily observe the value of variables, arrays, and classes. Echo reports an error as a dog. of course, we do not want software product customers to see var_dump output information in the output of common web pages, so echo is the most basic thing.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.