Php uses a trielement function to determine the parity of numbers. how can this problem be solved?

Source: Internet
Author: User
Php uses a trielement function to determine the parity error of numbers. how can I solve Parse error: syntax error, unexpected 'echo '(T_ECHO) in F: \ xampp \ htdocs \ test \ test02.php on line 26 this is an error description,

The source code is as follows:
For ($ a = 0; $ a <10; $ a ++ ){
// Output with a trielement operation. if there is no remainder, it is an even number,
Otherwise, it is an odd number.
Echo $ a % 2 = 0? $ A. "is an even number". "\ n": $ a. "is an odd number". "\ n ";
}
?>


Reply to discussion (solution)

// Otherwise, it is an odd number.

Thanks
The double slash is missing.

For ($ a = 0; $ a <10; $ a ++ ){
// Outputs the result using a ternary operation. if there is no remainder, the output result is an even number. Otherwise, the output result is an odd number.
Echo $ a % 2 = 0? $ A. "is an even number". "\ n": $ a. "is an odd number". "\ n ";
}

For ($ a = 0; $ a <10; $ a ++) {// outputs the result using a ternary operation. if there is no remainder, the result is an even number, // otherwise, it is an odd echo $ a % 2 = 0? $ A. "is an even number". "\ n": $ a. "is an odd number". "\ n ";}


0 is an even number. 1 is an odd number. 2 is an even number. 3 is an odd number. 4 is an even number. 5 is an odd number. 6 is an even number. 7 is an odd number. 8 is an even number. 9 is an odd number.

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.