Advertisement
zero50x

Извлечь название переменной из неё

Nov 24th, 2015
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.22 KB | None | 0 0
  1. function GetVarName($var) {
  2.     foreach($GLOBALS as $var_name => $value) {
  3.         if ($value === $var) {
  4.             return $var_name;
  5.         }
  6.     }
  7.     return null;
  8. }
  9.  
  10. $MyVar = 'test';
  11. echo GetVarName($MyVar);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement