英文:
If you want to see if a variable exists, use isset() as defined() only applies to constants. If you want to see if a function exists, use function_exists().
翻译:
<?php
/* 判断常量是否存在*/
if (defined('CONSTANT1')) {
echo CONSTANT1;
}
//判断变量是否存在
if (isset($myvar)) {
echo "$myvar.";
}
//判断函数是否存在
if (function_exists('open')) {
echo "存在函数open/n";
} else {
echo "函数open不存在/n";
}
?>