PHP从头开始-1

来源:互联网 发布:神优化游戏 编辑:程序博客网 时间:2024/06/05 03:47

基本语法

标记

起始标记:<?php
结束标记:?>
php会解析二者之间的代码。如果是纯php代码,最少删除结束标记,防止意外输出。

从HTML中分离

当php解释器遇到?>时就原样输出后面的内容。

条件语句的高级分离术

条件语句是一个例外,php解释器会判断输出哪些,跳过哪些。当条件未达成时会直接跳过该段条件语句块。

<?php  if ( $expression  ==  true ):  ?>  This will show if the expression is true.<?php  else:  ?>  Otherwise this will show.<?php  endif;  ?> 

输出大段文本的时候,跳出php解析模式比使用echo输出更有效率。

开始和结束标记

可以在 PHP 中使用四对不同的开始和结束标记。其中两种,

指令分隔符

每个语句后面用分号结束指令。——》;

注释

单行注释:
//this is a one-line c++ style comment
单行注释:
#this is a one-line shell style comment
多行注释:

/*this is a multi line commmentyet another line of comment*/
0 0
原创粉丝点击