函数defined

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

语法:bool defined ( string $name )。

补充说明:

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

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

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

 

案例:

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

 

 

posted @ 2012-08-16 10:14  TBHacker  阅读(1630)  评论(0编辑  收藏  举报