Home > php教程 > php手册 > php 如何得到函数的参数名

php 如何得到函数的参数名

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 09:52:26
Original
1838 people have browsed it



问题
如何得到函数的参数名?
解决方法
$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' 这个字符串.. 即参数名 而不是参数值..

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template