转载自**程序员笔记**
欢迎访问“程序员笔记”
/**
- 引入插件
- $name 插件名称
- $inbo 是否初始化
-
p
a
r
a
m
1
,
2
,
参
数
∗
/
f
u
n
c
t
i
o
n
c
(
param1,2,参数 */ function c(
param1,2,参数∗/functionc(name, $inbo=true, $param1=’’, $param2=’’)
{
c l a s s = ′ ′ . class = ''. class=′′.name.‘Chajian’;
p a t h = ′ ′ . R O O T P A T H . ′ / i n c l u d e / c h a j i a n / ′ . path = ''.ROOT_PATH.'/include/chajian/'. path=′′.ROOTPATH.′/include/chajian/′.class.’.php’;
c l s = N U L L ; i f ( f i l e e x i s t s ( cls = NULL; if(file_exists( cls=NULL;if(fileexists(path))
{
include_once( p a t h ) ; i f ( path); if( path);if(inbo)$cls = new c l a s s ( class( class(param1, $param2);
}
return $cls;
}
/**
- 引入class文件
*/
function import($name, $inbo=true)
{
c l a s s = ′ ′ . class = ''. class=′′.name.‘Class’;
p a t h = ′ ′ . R O O T P A T H . ′ / i n c l u d e / c l a s s / ′ . path = ''.ROOT_PATH.'/include/class/'. path=′′.ROOTPATH.′/include/class/′.class.’.php’;
c l s = N U L L ; i f ( f i l e e x i s t s ( cls = NULL; if(file_exists( cls=NULL;if(fileexists(path))
{
include_once( p a t h ) ; i f ( path); if( path);if(inbo)
{
$cls = new $class();
}
}
return $cls;
}
/**
- 判断变量是否为空
- @return boolean
*/
function isempt($str)
{
b o o l = f a l s e ; i f ( ( bool=false; if( ( bool=false;if((str==’’|| s t r = = N U L L ∣ ∣ e m p t y ( str==NULL||empty( str==NULL∣∣empty(str)) && (!is_numeric( s t r ) ) ) str)) ) str)))bool=true;
return $bool;
}
/**
- 判断变量是否包含在另一变量里面
- @return boolean
*/
function contain( s t r , str, str,a)
{
b o o l = f a l s e ; i f ( ! i s e m p t ( bool=false; if(!isempt( bool=false;if(!isempt(a) && !isempt($str))
{
a d = s t r p o s ( ad=strpos( ad=strpos(str, a ) ; i f ( a); if( a);if(ad>0||!is_bool( a d ) ) ad)) ad))bool=true;
}
return $bool;
}
/**
- 获取请求的头
- @return string/array
*/
function getheader($key=’’)
{
a r r = a r r a y ( ) ; i f ( f u n c t i o n e x i s t s ( ′ g e t a l l h e a d e r s ′ ) ) arr = array(); if(function_exists('getallheaders')) arr=array();if(functionexists(′getallheaders′))arr = getallheaders();
if($key==’’)return a r r ; r e t u r n a r r v a l u e ( arr; return arrvalue( arr;returnarrvalue(arr, $key);
}
/**
- 是否ajax请求
- @return boolean
*/
function isajax()
{
if(strtolower(getheader(‘X-Requested-With’))==‘xmlhttprequest’){
return true;
}else{
return false;
};
}
/**
- 过滤字符串的空格
*/
function trimstr(KaTeX parse error: Double superscript at position 34: …(str_replace(' '̲,'',str));
}