Home > Backend Development > PHP Tutorial > Alternative Syntax in PHP_PHP Tutorial

Alternative Syntax in PHP_PHP Tutorial

WBOY
Release: 2016-07-13 10:22:31
Original
743 people have browsed it

Alternative syntax in PHP

I took a look at the wordpress code today, and there are some rare php alternative syntaxes in it,

<?php else : ?>
		<div class="entry-content">
			<?php the_content( __( &#39;Continue reading <span class="meta-nav">→</span>&#39;, &#39;thebox&#39; ) ); ?>
			<?php wp_link_pages( array( &#39;before&#39; => &#39;<div class="page-links">&#39; . __( &#39;Pages:&#39;, &#39;thebox&#39; ), &#39;after&#39; => &#39;</div>&#39; ) ); ?>
		</div><!-- .entry-content -->
	<?php endif; ?>
Copy after login
What do the colon and endif after else mean? I'm a newbie, I haven't seen it before, so I googled it and realized that this is an alternative syntax for PHP,

Colon (:) is equivalent to the left curly bracket ({), endif is equivalent to the right curly bracket (});


Let’s give an example:

It’s a negative number

The above statement is equivalent to

It’s a negative number



What are the alternative syntaxes in PHP?
There are alternative syntaxes for flow control (including if, while, forforeach, switch) statements.


Basic form of alternative syntax:
Replace the left curly brace ({) with a colon (:), and replace the right curly brace (}) with endif;, endwhile;, endfor;, endforeach; and endswitch;

while alternative syntax:

  • What to loop


  • Other alternative syntaxes can be derived by analogy.

    www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/847859.htmlTechArticleAlternative syntax in PHP Today I looked at the wordpress code, and there are some rare php alternative syntax, →, thebox ) ); ?> . __( Pages:, thebox ), after => ) ); ?> The colon after else...
    Related labels:
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template