How to obtain the function parameter name_php tutorial

Source: Internet
Author: User
How does php obtain the function parameter name. How can I get the parameter name of the function? Solution $ testthisisatest; $ abcaaaaaaaaa; getit ($ test); functiongetit ($ l) {get the name of $ l here instead of the value when the problem occurs.
How do I get the function parameter name?
Solution
$ Test = 'This is a test ';

$ Abc = 'aaaaaaaaa ';

Getit ($ test );



Function getit ($ l ){

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

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

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



}


[]


Reference answer
This .. Is this useful?

It does not seem to be possible.

Unless you read the file and use regular expression matching.
Reference answer
Original post published by wbsifan at [url = http://bbs.111cn.cn/redirect.php? Goto = findpost & pid = 814417 & ptid = 100342] link Mark [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 $ l name instead of the value here
// When $ test is used as the parameter input, the string '$ test' is displayed instead of the value of $ test.
// When $ abc...
According to your application?
Getit ('aaa ');
What should I display? [Img] http://www.111cn.cn/bbs/images/smilies/default/03.gif#/img]
Reference answer
Meaning. [Img] http://www.111cn.cn/bbs/images/smilies/default/lol.gif#/img]
Reference answer
Don't worry about this...
Help me think about how to get the parameter name...
Reference answer
Learning
Reference answer
I don't quite understand what you mean. in c ++, there is a reference to pass the value, pointer to pass the value, 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 ));





?>



Reference answer
I understand what you mean, but I don't know how to implement it. I never thought about learning before ·~ ··
Reference answer
Int (1)
Array ([0] => 1 [1] => 2 [2] => 3)

To obtain the '$ arr' string... that is, the parameter name rather than the parameter value ..

How does the handler get the function parameter name? Solution $ test = 'This is a test'; $ abc = 'aaaaaaaaa'; getit ($ test); function getit ($ l) {// Get $ l name instead of value here // when...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.