Reply to Re: Easy question, return variable name

Your name:

Reply:


Posted by Iván Sánchez Ortega on 12/15/06 01:02

Tom wrote:

> Sorry, I should have been more specific -- I need the actual name of
> the variable itself, not its datatype. So, I need function that does
> the following:
>
> <?php
>
> $myArray = array( );
> $myVariable = "foobar";
>
> echo some_function($myArray); // should echo "myArray"
> echo some_function($myVariable); // should echo "myVariable"
>
> ?>

No can do. Please have a in-depth look at the PHP manual,
chapter "References to variables".

I'll try to show you the inability to know the *name* of a variable. And,
please, before replying, do RTFM.

<?php

$a = "foobar";
$b =& $a;
$c =& $a;
$d =& $a;

unset($a);

echo some_function($c); // WTF??

?>

Now, in your opinion, what should this return?? $b, $c and $d all point to
the same memory address, because of how references work. And the name $a,
which originated that memory address, does not exist. So, do we
return 'b', 'c' or 'd'??

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Razón #10 : Niegas vivamente la existencia de miles de dioses adorados por
otras religiones, pero te invade la ira cuando alguien niega la existencia
del tuyo.
-- Una de las jocosas, pero no por eso menos ciertas, Diez señales de
que eres un fundamentalista

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация