Skip to main content
Commonmark migration
Source Link

#PHP

PHP

function f($v){foreach($GLOBALS as$n=>$x)$x!=$v?:die($n);}

if value is found, print variable name and exit. print nothing and don´t exit else.

61 bytes to return variable name or NULL:

function f($v){foreach($GLOBALS as$n=>$x)if($x==$v)return$n;}

It will not find named functions, only those assigned to variables.
And a PHP function cannot detect wether a parameter was provided by reference or by value. The function will just return the first name where the value matches the function parameter value.

Test it online

#PHP

function f($v){foreach($GLOBALS as$n=>$x)$x!=$v?:die($n);}

if value is found, print variable name and exit. print nothing and don´t exit else.

61 bytes to return variable name or NULL:

function f($v){foreach($GLOBALS as$n=>$x)if($x==$v)return$n;}

It will not find named functions, only those assigned to variables.
And a PHP function cannot detect wether a parameter was provided by reference or by value. The function will just return the first name where the value matches the function parameter value.

Test it online

PHP

function f($v){foreach($GLOBALS as$n=>$x)$x!=$v?:die($n);}

if value is found, print variable name and exit. print nothing and don´t exit else.

61 bytes to return variable name or NULL:

function f($v){foreach($GLOBALS as$n=>$x)if($x==$v)return$n;}

It will not find named functions, only those assigned to variables.
And a PHP function cannot detect wether a parameter was provided by reference or by value. The function will just return the first name where the value matches the function parameter value.

Test it online

deleted 10 characters in body
Source Link
Dada
  • 8.5k
  • 1
  • 17
  • 43

#PHP, 58 bytes

function f($v){foreach($GLOBALS as$n=>$x)$x!=$v?:die($n);}

if value is found, print variable name and exit. print nothing and don´t exit else.

61 bytes to return variable name or NULL:

function f($v){foreach($GLOBALS as$n=>$x)if($x==$v)return$n;}

It will not find named functions, only those assigned to variables.
And a PHP function cannot detect wether a parameter was provided by reference or by value. The function will just return the first name where the value matches the function parameter value.

Test it online

#PHP, 58 bytes

function f($v){foreach($GLOBALS as$n=>$x)$x!=$v?:die($n);}

if value is found, print variable name and exit. print nothing and don´t exit else.

61 bytes to return variable name or NULL:

function f($v){foreach($GLOBALS as$n=>$x)if($x==$v)return$n;}

It will not find named functions, only those assigned to variables.
And a PHP function cannot detect wether a parameter was provided by reference or by value. The function will just return the first name where the value matches the function parameter value.

Test it online

#PHP

function f($v){foreach($GLOBALS as$n=>$x)$x!=$v?:die($n);}

if value is found, print variable name and exit. print nothing and don´t exit else.

61 bytes to return variable name or NULL:

function f($v){foreach($GLOBALS as$n=>$x)if($x==$v)return$n;}

It will not find named functions, only those assigned to variables.
And a PHP function cannot detect wether a parameter was provided by reference or by value. The function will just return the first name where the value matches the function parameter value.

Test it online

Source Link
Titus
  • 14.8k
  • 1
  • 24
  • 41

#PHP, 58 bytes

function f($v){foreach($GLOBALS as$n=>$x)$x!=$v?:die($n);}

if value is found, print variable name and exit. print nothing and don´t exit else.

61 bytes to return variable name or NULL:

function f($v){foreach($GLOBALS as$n=>$x)if($x==$v)return$n;}

It will not find named functions, only those assigned to variables.
And a PHP function cannot detect wether a parameter was provided by reference or by value. The function will just return the first name where the value matches the function parameter value.

Test it online