Introduction to alternative syntax in PHP and introduction to alternative syntax in PHP _ PHP Tutorial

Source: Internet
Author: User
Introduction to alternative syntax in PHP and introduction to alternative syntax in PHP. Introduction to alternative syntax in PHP. Introduction to alternative syntax in PHP today I checked the wordpress code, which contains some rare Alternative php syntax. the copied code is as follows: Introduction to alternative syntax in phpelse: divclass PHP, PHP alternative syntax

Today I read the wordpress code, which contains some rare Alternative php syntax,

The code is as follows:


<? Php else:?>


<? Php the_content (_ ('continue reading → ', 'thebox');?>
<? Php wp_link_pages (array ('before' =>'

'. _ ('Pages:', 'thebox'), 'after' =>'

');?>


<? Php endif;?>

What do the colons and endif after else represent? I have never met a Cainiao, so I just googled it to understand that this is an alternative syntax for php,

Colon (:) is equivalent to Left curly braces ({), and endif is equivalent to right curly braces (});

For example:

The code is as follows:


<? Php if ($ a <0):?>


Is a negative number.

The code is as follows:


<? Php endif;?>


The preceding statement is equivalent

The code is as follows:


<? Php if ($ a <0) {?>


Is a negative number.

The code is as follows:


<? Php }?>

Which of the following statements in PHP have alternative syntaxes?

Process control (including if, while, forforeach, switch) statements have alternative syntax.

The basic form of alternative syntax:

Replace Left curly braces ({) with colons (:), and change right curly braces (}) with endif;, endwhile;, endfor;, endforeach; and endswitch;

While alternative syntax:

The code is as follows:


<? Php while (expr):?>

  • Loop point

  • <? Php endwhile;?>


    Other alternative syntaxes can be similar.

    Today, I checked the wordpress code, which contains some rare Alternative php syntax. the code is as follows: php else: p class = "...

    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.