Home > Backend Development > PHP Tutorial > How to get the parameter name of a function in php_PHP Tutorial

How to get the parameter name of a function in php_PHP Tutorial

WBOY
Release: 2016-07-13 10:50:52
Original
1236 people have browsed it



Question
How to get the parameter name of a function?
Solution
$test = 'this is a test';

$abc = 'aaaaaaaaa';

getit($test);



function getit($l){

// Get the name of $l here instead of the value

// When $test does parameter input, the string '$test' is displayed instead of the value of $test

// When $abc is used as parameter input, the string '$abc' is displayed instead of the value of $abc



}


Copy code [ ]


Reference answer
this. . Does this work?

Can't seem to get it.

Unless you read the file, use regular matching.
Reference answer
Original post by wbsifan on 2009-1-4 10:46 [url=http://bbs.111cn.cn/redirect.php?goto=findpost&pid=814417&ptid=100342]Link tag [img]http://bbs. 111cn.cn/images/common/back.gif[/img][/url]

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

function getit($l){
// Get the name of $l here instead of the value
// When $test does parameter input, the string '$test' is displayed instead of the value of $test
// When $abc ...
What’s your application?
getit('aaa');
What should be displayed? [img]http://www.111cn.cn/bbs/images/smilies/default/03.gif[/img]
Reference answer
significance. [img]http://www.111cn.cn/bbs/images/smilies/default/lol.gif[/img]
Reference answer
Don’t think about this yet...
Help me figure out how to get the parameter name...
Reference answer
Studying
Reference answer
I don’t quite understand what you mean. There is a pass-by-reference-by-value and pointer-by-value approach in C++, which may be useful to you
Reference answer




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));





?>


Copy code
Reference answer
I understand what you mean but I don’t know how to implement it. I have never thought about it before. Learn·~··
Reference answer
int(1)
Array ( [0] => 1 [1] => 2 [2] => 3 )

To get the string '$arr'...that is, the parameter name instead of the parameter value..

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632603.htmlTechArticleProblem How to get the parameter name of the function? Solution $test = 'this is a test'; $abc = ' aaaaaaaaa'; getit($test); function getit($l){ // Get the name of $l here instead of the value // When...
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template