PHP: Colon, endif, endwhile, endfor

Source: Internet
Author: User
Tags wordpress blog
: This article mainly introduces PHP: Colon, endif, endwhile, and endfor. For more information about PHP tutorials, see. We often see many strange PHP syntaxes in the templates of wordpress blog programs, such:

[Php] view plaincopy

  1. "Red"> empty

For a considerable number of PHP enthusiasts, what are these things? In fact, these are alternative syntaxes for PHP process control, but they are not commonly used.
The following describes the alternative syntax of PHP process control.
1. what is an alternative syntax?
Simply put, it is an alternative way of writing some syntaxes.
2. what syntax does PHP have?
If, while, for, forforeach, and switch process control statements have alternative syntaxes.
3. basic form of alternative syntax:
Replace Left curly braces ({) with colons (:), and change right curly braces (}) with endif;, endwhile;, endfor;, endforeach; and endswitch;
Example:

[Php] view plaincopy

  1. Is a negative number.
  2. The preceding statement is equivalent
  3. Is a negative number.


4. everyone is not used to it. what is the purpose of this alternative?
Existence is reasonable, and it has its own use. these syntaxes can be used in the code of PHP and HTML hybrid pages. Benefits:
1) make the HTML and PHP mixed page code more clean and tidy.
2) the process control logic is clearer and the code is easier to read.

The above introduces PHP: Colon, endif, endwhile, endfor, including some content, hope to be helpful to friends who are interested in PHP tutorials.

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.