Home > Backend Development > PHP Tutorial > PHP中的代替语法

PHP中的代替语法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 12:01:55
Original
953 people have browsed it

PHP中的替代语法

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

<?php else : ?>		<div class="entry-content">			<?php the_content( __( &#39;Continue reading <span class="meta-nav">→', 'thebox' ) ); ?>			<?php wp_link_pages( array( &#39;before&#39; => '<div class="page-links">' . __( 'Pages:', 'thebox' ), 'after' => '</div>' ) ); ?>		</div><!-- .entry-content -->	<?php endif; ?>
Copy after login
else后面的冒号和endif代表啥?菜鸟一个,没有见过,所以就google了一下,才明白这是php的替代语法,

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


    举个例子吧:

是负数拉

上面的语句等同于

是负数拉



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


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

while替代语法:

 

  • 循环点什么


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

    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
    Latest Issues
    php data acquisition?
    From 1970-01-01 08:00:00
    0
    0
    0
    PHP extension intl
    From 1970-01-01 08:00:00
    0
    0
    0
    How to learn php well
    From 1970-01-01 08:00:00
    0
    0
    0
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template