You are here: Get name of passed variable in a function « PHP Programming Language « IT news, forums, messages
Get name of passed variable in a function

Posted by Adam on 10/25/61 11:28

I've cobbled a sort of global "debug" routine by using this function:

function debug($str, $strname) {
global $debugYN;
if ($debugYN) {
echo "<br>[Debug (<span
style=\"color:red\">$$strname</span>) : <strong>$str</strong>]<br>";
}
}

This function gets included (usually in a header) and then called by
setting $debugYN = 1 wherever I want to start viewing variable info -
calling the function with:

debug($foo, "foo");

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?

Adam.

 

Navigation:

[Reply to this 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

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