"Turn" Php:echo, print, Print_r, sprintf, Var_dump in the course of the difference

Source: Internet
Author: User
"Turn" the difference between Php:echo, print, Print_r, sprintf, Var_dump

-Echo
is a command and cannot return a value. Echo can be followed by a number of parameters, separated by semicolons, such as:

Echo $myvar 1 ; Echo 1 , 2 , $myvar , "Bold" ;

-Print
is a function that returns a value that can have only one parameter.

-printf
function to format the text for later output, such as:

$name = "Hunte" ; $age =  - ; printf (%s%d",$name,$age  );

-sprintf
Similar to printf, but does not print, but returns formatted text, the rest is the same as printf.

-Print_r
Print_r are typically used to print information about variables, which are typically used in debugging.

Print_r (true) ;           //Output 1 Print_r (false) ;          //No output Print_r (null) ;          //No output

-Var_dump
Var_dump This function displays structure information about one or more expressions, including the type and value of the expression.

Var_dump (true) ; //output bool (TRUE) Var_dump (false) ;   //bool (FALSE) Var_dump (null) ;   //bool (NULL)

The difference between var_dump () and Print_r ():
Var_dump returns the type and value of the expression and Print_r only returns the result, which is easier to read than the debug code using Var_dump.

< PHP >

  • 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.