Reply to Re: Get name of passed variable in a function

Your name:

Reply:


Posted by Andy Hassall on 11/16/45 11:28

On Mon, 03 Oct 2005 22:29:48 +0200, Ewoud Dronkert
<firstname@lastname.net.invalid> wrote:

>Andy Hassall wrote:
>> In short, no.
>
>Yes, http://php.net/debug-backtrace

No,

<pre>
<?php
function debug($var) {
print_r(debug_backtrace());
}

$foo = 10;
debug($foo);

?>
</pre>

Output:

Array
(
[0] => Array
(
[file] => /home/andyh/public_html/test.php
[line] => 8
[function] => debug
[args] => Array
(
[0] => 10
)

)

)

If you can find "foo" in the above then it would do what the OP requested:

>>I'm having to pass two values - the value of the variable AND it's
>>name. Is there a way of extracting the NAME of the variable ("foo" in
>>this case) without having to pass it?
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

[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

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