PHP头条
热点:

php 如何得到函数的参数名




问题
如何得到函数的参数名?
解决方法
$test = 'this is a test';

$abc = 'aaaaaaaaa';

getit($test);



function getit($l){

// 此处获得 $l 的名称 而不是值

// 当$test 做参数输入时, 显示 '$test' 这个字符串, 而不是 $test 的值

// 当$abc 做参数输入时, 显示 '$abc' 这个字符串, 而不是 $abc 的值



}


复制代码[ ]


参考答案
这。。这有用吗?

好像不能得到。

除非你把文件读取过来,用正则匹配。
参考答案
原帖由 wbsifan 于 2009-1-4 10:46 发表 [url=http://bbs.111cn.cn/redirect.php?goto=findpost&pid=814417&ptid=100342]链接标记[img]http://bbs.111cn.cn/images/common/back.gif[/img][/url]

$test = 'this is a test';
$abc = 'aaaaaaaaa';
getit($test);

function getit($l){
// 此处获得 $l 的名称 而不是值
// 当$test 做参数输入时, 显示 '$test' 这个字符串, 而不是 $test 的值
// 当$abc ...
照你这种应用?
getit('aaa');
应该显示什么? [img]http://www.111cn.cn/bbs/images/smilies/default/03.gif[/img]
参考答案
意义。[img]http://www.111cn.cn/bbs/images/smilies/default/lol.gif[/img]
参考答案
这个先别考虑了...
帮我想想如何得到参数名...
参考答案
学习中
参考答案
不太明白你的意思,c++里面有一个引用传值,指针传值,可能会对你有用
参考答案




function test($val) {



if (is_array($val)){



foreach($val as $value){



$arr[]=$value;



}

return $arr;



}else {



$val = &$val;

return $val;



}



}

$val = 1;

var_dump(test($val));



echo "
";



$arr = array(1,2,3);

print_r(test($arr));





?>


复制代码
参考答案
明白你的意思 但是不知道怎么实现 以前没想过 学习·~··
参考答案
int(1)
Array ( [0] => 1 [1] => 2 [2] => 3 )

要获得 '$arr' 这个字符串.. 即参数名 而不是参数值..

www.phpzy.comtrue/php/30441.htmlTechArticlephp 如何得到函数的参数名 问题 如何得到函数的参数名? 解决方法 $test = 'this is a test'; $abc = 'aaaaaaaaa'; getit($test); function getit($l){ // 此处获得 $l 的名称 而不是值 // 当$test 做参数输入时,...

相关文章

    暂无相关文章

PHP之友评论

今天推荐