Printing of php-variables

Source: Internet
Author: User

Printing of variables
为什么要打印变量?因为在做开发的时候,我想看看现在这个值变成多少了,或者是否达到目的了。 所以需要打印变量来看看
PHP provides printing functions
echo(),print_r(),var_dump()使用中,echo 后面通常不加括号,而其他两个需要加、echo 比较使用来打印字符串和数字print_r 用来打印数组方便一些var_dump 所有类型都可以,打印变量的类型及其值    比如来了一个21,那到底是整型的21还是字符串的21,那么这个时候就比较适合用var_dump来打印,可以看得更清楚
Example:
  $a = 1;echo $a; output: 1//When you do not know what type such as the following Boolean value $ A = True;echo $a; output: 1//output is also 1$a = True;var_dump ($a); output: Boolean True// This is clear as $ A = Array (' Chen ', ' Li ', ' Wang ', ' Jin ');p rint_r ($a); output: Array ([0] = Chen [1] = [2] [+] = [+] = li [+] = Wang [3] = Ji N) Clear results for easy debugging Print_r typically prints an array using the  

PS: When precise debugging is required, use the print function selectively

Printing of php-variables

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.