Differences between echo and print in php

Source: Internet
Author: User
Tags echo command
Welcome to the Linux community forum and interact with 2 million technical staff about the differences between echo and print usage in php. Echo Description: echo can output multiple strings at the same time without parentheses. echo is more like a statement. echo is recommended ;? Phpecho and so on. I haven't finished writing it yet. Connect the above .;? Echo () No Return

Welcome to the Linux community forum, and interact with 2 million technical staff> what is the usage difference between echo and print in php. Echo Description: echo can output multiple strings at the same time without parentheses. echo is more like a statement. echo is recommended ;? Php echo 'and so on. I haven't finished writing it yet. Click here. ';? Echo () No Return

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

Differences between echo and print in php.

Echo description:

Echo can output multiple strings at the same time without parentheses;

Echo is more like a statement;

Echo is recommended;

Echo 'and so on. I haven't finished writing it yet. Click here. ';

?>

Echo () has no return value, which is the same as the echo command;

Echo can have multiple parameters, and echo does not return values.

Print description:

Print can only output one string at a time, and parentheses are required.

Print is a function;

The usage of print is similar to that of C language, so it will make a special explanation of % in the output content;

There is no big difference, that is, a function, and a command.

Print can also be used like this

Print <

Php self-learning Network

DND

?>

In this way, you can output a large HTML segment without escaping the quotation marks.

Automatically replace the variables

Print a parameter. print has, true, 1; false, 0.

Difference details:

The echo command is the same as the print command, and there is no difference;

The echo function differs from the print function;

Print () has a returned value. If the execution fails (such as disconnection), flase is returned;

Both printf () and sprintf () are formatted outputs. The difference is that the former is output to the standard output, and the latter is output to the variable.

Use in the same page < <标记,标记名为配对出现,同一页面中不允许同名出现两个以上标记名。配对标记名的结尾标记名应单独一行,前后均不允许输出字符…(例如空格等不可见但存在的字符) 。< p>

Shape

Echo <EOT

EOT;

Print <EOT

EOT;

The format, meaning:

<Operator, which treats the content between custom delimiters as strings and processes the variables

EOT User-Defined delimiters. The end must be at the beginning of the line.

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.