Echo and Var_dump

Source: Internet
Author: User
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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.