The execution body {} in the php condition statement can be replaced? Solution

Source: Internet
Author: User
The execution body {} in the php condition statement can be replaced ?? The execution body {} in the php condition statement can be replaced ?? I recently read a code from someone else and found an interesting thing I didn't know before, and I didn't say it in the book. For example, if ($ a = 1) {// execution Statement} of the normally written judgment statement can also be found here if ($ a = 1): // execution statement endif; the execution body {} in the second php condition statement can be replaced ??
The execution body {} in the php condition statement can be replaced ??

I recently read a code from someone else and found an interesting thing I didn't know before, and I didn't say it in the book.

For example, a normal write judgment statement
If ($ a = 1)
{
// Execute the statement
}
Now you can find that
If ($ a = 1 ):
// Execute the statement
Endif;


The second method is actually a compatible way of writing like this. do you know if this affects performance ??
Ask a friend to answer this question ....

------ Solution --------------------
Http://php.chinaunix.net/manual/zh/migration.if-endif.php

Earlier versions of the syntax are not recommended.
------ Solution --------------------
Alternative process control syntax in PHP:

PHP provides alternative syntaxes for process control, including if, while, for, foreach, and switch.

The basic form of the alternative syntax is to replace left curly braces ({) with colons (:), and change right curly braces (}) with endif;, endwhile;, endfor;, endforeach; and endswitch respectively.

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.