What is the difference between echo (), print (), Print_r ()? _php Tips

Source: Internet
Author: User
ECHO is a PHP statement, print and Print_r are functions, statements have no return value, and functions can have return values (even if they are not used)
Print only prints out the values of simple type variables (such as int,string)
Print_r can print out the values of complex type variables (such as arrays, objects)

echo--output one or more strings
Description
void Echo (String arg1 [, String ...])//return value is NULL
echo "Hello", "friend";


Print--Output a string
Description
int print (string arg)//return value is cosmetic
print "Hello friend";

You can do these things
$name =print "Nihao \";
$STR = ' Test print value is $name. ';
Eval ("$print =\" $str \ ";");
Echo $print;

Print_r--Print easy to understand information about variables.
BOOL Print_r (mixed expression [, bool return])//Returns the value is Boolean, the parameter is a mix type, can be a string, shaping, array, object class Print_r () to display information about a variable easily understandable. If a string, integer, or float is given, the variable value itself is printed. If you give an array, the keys and elements will be displayed in a certain format. object is similar to an array.
Print_r () Moves the pointer to the last edge of the array.
You can
Print_r (str);
Print_r (int);
Print_r (array);
Print_r (obj);
You can also use Var_dump Var_export

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.