Get the PHP variable name

Source: Internet
Author: User
<? Php/* Get the variable name */function getVarName (& $ src) {// store the current variable value $ save = $ src; // store all variable values $ allvar = $ GLOBALS; // do not directly traverse $ GLOBALS in the function. A stack issue occurs in foreach ($ allvar as $ k => $ v) {// The variable value is the same and may not be the same variable, because the values of multiple variables may be the same if ($ src = $ v) {// change the value of the current variable $ src = 'change'; // If $ GLOBALS [$ k] also changes, it is the same variable. If ($ src = $ GLOBALS [$ k]) {echo "/$ k name is $ k <br/> ";}}} // restore the variable value $ src = $ save;} $ test = "helo"; $ test2 = "helo"; getVarName ($ test);?>

The disadvantage is that only the current page can be obtained

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.