今天写的PHP小东东
时间:2007-05-02 来源:liuxingyuyuni
一个动态载入PHP方法的例子.暂时还不能同时载入多个.明天继续弄
请网友PP,有好的也顶上来.
?php
$rootPath = dirname(__FILE__);
$cfg_functions = array(
'happy' => $rootPath.'happy.php',
'angry' => $rootPath.'angry.php'
);
/**
* @name 载入函数
* @param $funsList=> 已经存在的函数已数组形式存放
* @param $funName=> 调用的函数名称
* @param $dir=> 函数所在路径
* */
function loadfnc($funName, $funsList, $dir)
{
if(!preg_match('{/$}', $dir))
{
$dir .= '\\';
}
$keys = array_keys($funsList);
if(in_array($funName, $keys))
{
if(file_exists($dir))
{
include($dir.$funName.".php");
}
}
}
//载入函数
loadfnc('happy', $cfg_functions, 'D:\bianjiang\test\fns');
//执行函数
happy();
?>
请网友PP,有好的也顶上来.
?php
$rootPath = dirname(__FILE__);
$cfg_functions = array(
'happy' => $rootPath.'happy.php',
'angry' => $rootPath.'angry.php'
);
/**
* @name 载入函数
* @param $funsList=> 已经存在的函数已数组形式存放
* @param $funName=> 调用的函数名称
* @param $dir=> 函数所在路径
* */
function loadfnc($funName, $funsList, $dir)
{
if(!preg_match('{/$}', $dir))
{
$dir .= '\\';
}
$keys = array_keys($funsList);
if(in_array($funName, $keys))
{
if(file_exists($dir))
{
include($dir.$funName.".php");
}
}
}
//载入函数
loadfnc('happy', $cfg_functions, 'D:\bianjiang\test\fns');
//执行函数
happy();
?>
相关阅读 更多 +
排行榜 更多 +