任何php脚本语言都是使用连续的语句创建的。一个语句可以是一个赋值语句,一个函数调用,一个循环,一个条件语句甚至一个不做任何事情的语句(一个空的语句)。语句经常使用分号(;)结尾。另外,利用卷支持可以把一组语句压缩从而使语句可以被组成语句组。 一个语句组是一个关于自身的申明。不同的语句类型将在本章被描述。
常量
php定义了一些常量提供给结构使它能够在运行时定义更多的类型。常量和变量十分的类似,但是他们在语法上有些微的不同。
被预定义的常量是__file__ 和__line__,在处理他们时,会发现他们与文件名和行号相符合。请参考如下示例:
example 6-1. using __file__ and __line__ //使用__file__ 和__line__
<?php
function report_error($file, $line, $message) {
echo "an error occured in $file on line $line: $message.";
}
report_error(__file__,__line__, "something went wrong!");
?>
您可以使用函数define() 和undefine()来定义其它的常量。
example 6-2. defining constants //定义常量
<?php
define("constant", "hello world.");
echo constant; // outputs "hello world."
undefine ("constant");
?>
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器