Maison  >  Article  >  développement back-end  >  PHP中的替代语法_PHP教程

PHP中的替代语法_PHP教程

WBOY
WBOYoriginal
2016-07-13 10:22:31692parcourir

PHP中的替代语法

今天看了一下wordpress的代码,里面有些少见的php替代语法,

<?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; ?>
else后面的冒号和endif代表啥?菜鸟一个,没有见过,所以就google了一下,才明白这是php的替代语法,

冒号(:)等价于左花括号({),endif等价于右花括号(});


举个例子吧:

是负数拉

上面的语句等同于

是负数拉



PHP中那些语法有替代语法?
流程控制(包括if,while,forforeach,switch)这几个语句有替代语法。


替代语法的基本形式:
左花括号({)换成冒号(:),把右花括号(})分别换成 endif;,endwhile;,endfor;,endforeach; 以及 endswitch;

while替代语法:

  • 循环点什么


  • 其它替代语法可以类推。

    www.bkjia.comtruehttp://www.bkjia.com/PHPjc/847859.htmlTechArticlePHP中的替代语法 今天看了一下wordpress的代码,里面有些少见的php替代语法, → , thebox ) ); ?> . __( Pages:, thebox ), after => ) ); ?> else后面的冒号...
    Déclaration:
    Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn