Echo (), print (), print in PHP

Source: Internet
Author: User
Welcome to the Linux community forum and interact with 2 million technical staff to access echo. The difference between print is that echo can output multiple variable values, while print only has one variable, which is output as a string. Another difference is that echo does not return values. print has returned values. 1. print cannot output arrays and objects. Print_r can output stirng and in

Welcome to the Linux community forum, interact with 2 million technical staff> go to echo. The difference in print is that echo can output multiple variable values, while print has only one variable, which is output as a string. Another difference is that echo does not return values. print has returned values. 1. print cannot output arrays and objects. Print_r can output stirng and in

Welcome to the Linux community forum and interact with 2 million technicians>

The difference between echo and print is that echo can output multiple variable values, while print only has one variable and is output as a string. Another difference is that echo does not return values. print has returned values. 1. print cannot output arrays and objects.

Print_r can output stirng, int, float, array, object, etc. The structure is used to output the array, and true is returned when the print_r output is successful;

In addition, print_r can use print_r ($ str, true) to make print_r output and return the value after print_r processing.

It can be understood:

Print is a print string

Print_r prints composite types such as array objects.

In PHP, the execution speed is from fast to slow: echo (), print (), print_r ()

Echo is a PHP statement, print and print_r are functions, and the statement does not return values. The function can return values (even if it is not used)

Print () can only print values of simple type variables (such as int and string)

Print_r () can print values of complex types of variables (such as arrays and objects)

Echo outputs one or more strings

Echo -- output one or more strings

Descr resume ption

Void echo (string arg1 [, string…] ) // The returned value is null.

Echo "hello", "friend ";

Print -- output a string

Descr resume ption

Int print (string arg) // the return value is an integer.

Print "your good friend ";

You can perform the following operations:

$ Name = print "nihao/n ";

$ Str = 'test print value is $ name .';

Eval_r ("/$ print =/" $ str /";");

Echo $ print;

Print_r -- print easy-to-understand information about variables.

Bool print_r (mixed expression [, bool return]) // the return value is Boolean and the parameter type is mix. It can be a string, an integer, an array, and an object class print_r () displays easy-to-understand information about a variable. If the value is string, integer, or float, the variable value is printed. If array is provided, keys and elements are displayed in a certain format. Objects are similar to arrays.

[1] [2]

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.