首页 > 开发 > PHP > 正文

javascript,php获取函数参数对象的代码

2024-05-04 22:08:06
字体:
来源:转载
供稿:网友
例如:
代码如下:
function say () {
alert (arguments[0]+'说:'+arguments[1]);
}
say ('fanglor','fanglor is a boy !');

结果:弹出 fanglor 说:fanglor is a boy !
--------------------------------------------------------------------------------
这个有点类似于php 中的 func_get_args() 函数,也是获取函数参数的数组。
例(以下是php代码):
代码如下:
function uses () {
$args =func_get_args();
if (!empty($args)) {
foreach ($args as $key => $val ) {
if (file_exists($val.'.php')) {
include "{$val}.php";
} else {
if (DEBUG) {
echo "{$val}.php 不存在!";
}
}
}
}
}
//再次封装 include
uses ('config','db');

自动装载 config.php 和 db.php ,如不存在,显示 {__file__}.php不存在.
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表