Ask: Why for ($i =1; $i <=10;print $i + +); Can't I change the print to echo?

Source: Internet
Author: User
Tags parse error
Ask: Why for ($i =1; $i <=10;print $i + +); Can't I change the print to echo?


Reply to discussion (solution)

for ($i =1; $i <=10;echo $i + +);
Parse error:syntax error, unexpected ' echo ' (T_echo), expecting ') ' in ....
That's what it's all about.

What exactly is the need to print on for?

It's a strange notation.

for ($i =1; $i <=10;echo $i + +);
Parse error:syntax error, unexpected ' echo ' (T_echo), expecting ') ' in ....
That's what it's all about.


Start to think whether it is the return value of print and echo problem, but also want to understand, want to understand, seek guidance!

What exactly is the need to print on for?


Not the actual project, is to see the manual found the problem ...

It's a strange notation.


It's kind of weird, it's not usually written like that.

for ($i =1; $i <=10;echo $i + +);
Parse error:syntax error, unexpected ' echo ' (T_echo), expecting ') ' in ....
That's what it's all about.


Start to think whether it is the return value of print and echo problem, but also want to understand, want to understand, seek guidance!


Yes, it's a question of return value, ECHO has no return value, so it's not allowed to write.

Wrong syntax, change it.

for ($i =1; $i <=10; $i + +) {    echo $i;}

Wrong syntax, change it.

for ($i =1; $i <=10; $i + +) {    echo $i;}


I know it can be written like this, just to figure out why Echo replaces print with an error when a line is written.

for ($i = 1; $i <=; Echo $i, $i + +);

It's a really weird notation.

Wrong syntax, change it.

for ($i =1; $i <=10; $i + +) {    echo $i;}


I know it can be written like this, just to figure out why Echo replaces print with an error when a line is written.



The moderator has already answered you, because print succeeds always returns 1, and Echo has no return value, so the original statement is equivalent for ($i =1; $i <=10;1) {$i + +;} And for ($i =1; $i <=10;) {$i + +;}, obviously echo will go wrong.

Endorsement 7 Floor +1

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