函数defined

作用:defined检查某个名称的常量是否存在。

语法:bool defined ( string $name )。

补充说明:

1.如果你要检查一个变量是否存在,请使用 isset()

2.defined() 函数仅对 constants 有效。

3.如果你要检测一个函数是否存在,使用 function_exists()。

 

案例:

if ( ! defined('BASEPATH')) 
exit('No direct script access allowed'); 判断常量BASEPATH是否定义

 

原文地址:https://www.cnblogs.com/jiqing9006/p/2641723.html