define:定义一个常量
defined:确定一个常量是否存在,存在返回true,否则返回false
一般用法:
$env = get_cfg_var('env');
defined('YII_ENV') or define('YII_ENV', $env);
const:定义一个类常量,
const & define需要区别好,
const用于类成员变量,一经定义不可修改,define用于全局常量,不可用于类成员变量的定义,const可在类中使用,define不能
function_exists().:判断某个函数是否存在
isset():判断某个变量是否存在,存在返回true,否则返回false
isset() & defined()需要区别好,
Note:
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().
参考链接:const & define认识 : https://www.cnblogs.com/jiechn/p/3753853.html