bool setcookie ( string $name [, string $value [, int $expire = 0 [, string $path [, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]] ) explain:this requires that you place calls to this function prior to any output, including and tags as well as any whitespace. example:setcookie(testcookie, $value, time()+3600); bool define ( string $name , mixed $value [, bool $case_insensitive = false ] ) //定义一个常量 const constant = 'hello world'; //实用关键字const定义一个常量 ,效果一样 example:define(constant, hello world.); bool defined ( string $name ) //检查一个常量是否存在 bool isset ( mixed $var [, mixed $... ] ) //检查一个变量是否存在 void unset ( mixed $var [, mixed $... ] ) //释放一个变量 bool function_exists ( string $function_name ) //检查一个函数是否存在 string get_class ([ object $obj ] ) //获取一个对象的所属类名 array get_object_vars ( object $obj ) //返回由对象属性组成的关联数组 bool file_exists ( string $filename ) // 检查文件或目录是否存在 比较运算符 $a == $b等于,如果类型转换后 $a 等于 $b。 $a === $b全等,如果 $a 等于 $b,并且它们的类型也相同。 $a != $b不等,如果类型转换后 $a 不等于 $b。 $a $b不等,如果类型转换后 $a 不等于 $b。 $a !== $b不全等,如果 $a 不等于 $b,或者它们的类型不同。 $a $a > $b大于,如果 $a 严格大于 $b。 $a $a >= $b大于等于,如果 $a 大于或者等于 $b。 php 支持一个错误控制运算符:@。当将其放置在一个 php 表达式之前,该表达式可能产生的任何错误信息都被忽略掉。 执行运算符 , 反引号运算符在激活了安全模式或者关闭了 shell_exec() 时是无效的。 字符串运算符 有两个字符串(string)运算符。第一个是连接运算符(.),它返回其左右参数连接后的字符串。第二个是连接赋值运算符(.=),它将右边参数附加到左边的参数之后。 数组运算符 $a + $b联合 $a 和 $b 的联合。 $a == $b相等 如果 $a 和 $b 具有相同的键/值对则为 true。 $a === $b全等 如果 $a 和 $b 具有相同的键/值对并且顺序和类型都相同则为 true。 $a != $b不等 如果 $a 不等于 $b 则为 true。 $a $b不等 如果 $a 不等于 $b 则为 true。 $a !== $b不全等 如果 $a 不全等于 $b 则为 true。 类型运算符 instanceof 用于确定一个 php 变量是否属于某一类 class 的实例: 以上例程会输出: bool(true) bool(false) bool is_a ( object $object , string $class_name [, bool $allow_string = false ] ) //如果对象属于该类或该类是此对象的父类则返回 true foreach循环数组或者对象 foreach (array_expression as $value) statement foreach (array_expression as $key => $value) statement require 和 include几乎完全一样,除了处理失败的方式不同之外。 require在出错时产生 e_compile_error级别的错误。换句话说将导致脚本中止而 include只产生警告(e_warning),脚本会继续运行。 include 'vars.php'; require_once 语句和 require语句完全相同,唯一区别是 php 会检查该文件是否已经被包含过,如果是则不会再次包含。 goto: (相对于c语言就是一个阉割品) goto操作符可以用来跳转到程序中的另一位置。该目标位置可以用目标名称加上冒号来标记,而跳转指令是 goto 之后接上目标位置的标记。 php 中的 goto有一定限制,目标位置只能位于同一个文件和作用域,也就是说无法跳出一个函数或类方法,也无法跳入到另一个函数。也无法跳入到任何循环或者 switch 结构中。 可以跳出循环或者 switch,通常的用法是用 goto代替多层的 break。 以上例程会输出: bar
复制代码
php