<?php /* 判断常量是否存在*/ if (defined('MYCONSTANT')) { echo MYCONSTANT; } //判断变量是否存在 if (isset($myvar)) { echo "存在变量$myvar."; } //判断函数是否存在 if (function_exists('imap_open')) { echo "存在函数imag_open/n"; } else { echo "函数imag_open不存在/n"; } //判断类是否存在 if (class_exists('MyClass')) { $myclass = new MyClass(); } //判断文件是否存在 $filename = '/path/to/foo.txt'; if (file_exists($filename)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist"; } //判断数组中是否存在某成员 $os = array("Mac", "NT", "Irix", "Linux"); if (in_array("Irix", $os)) { echo "Got Irix"; } //判断变量类型 is_array() is_bool() is_float() is_integer() is_null() is_numeric() is_object() is_resource() is_scalar() is_string() ?>