NYCPHP Meetup

NYPHP.org

[nycphp-talk] Output name of Variable

Mark Armendariz nyphp at enobrev.com
Fri Jan 31 13:24:48 EST 2003


I can't seem to find much about finding the name of a variable, as I can
see how it would be helpful.  I suppose, if you wanted to change your
coding methods, you could have a vars array.  Where you could:

$vars = array();

... In the beginning of every script (or in your config file).  The rest
of your page using $vars['name'] throughout in place of variables and
then for debugging something like:

foreach($vars as $name => $value) {
	print $name . ': ' . $value . '<br />';
}

Come to think of it, I kinda like the idea (could probably make some
great variable management functions this way).

I suppose that would work for an overall means of debugging without
inserting debug variable display functions throughout the script.
Otherwise, I like David's solution.

Anyways... if you find a way, please pass it on...


Mark

-----Original Message-----
From: Jim Musil [mailto:jim at nettmedia.com] 
Sent: Friday, January 31, 2003 12:38 PM
To: NYPHP Talk
Subject: [nycphp-talk] Output name of Variable



It seems like it would be helpful if there were a way to grab the name
assigned to a variable and output it. Is there already a function like
this?

I would use this mainly for tracing and reporting. So, if I had a simple
function show_variable($var), it would not only output the value
assigned to the variable, but would also show the name of the variable
itself.

Am I missing it?


Jim Musil
<jim at nettmedia.com>
Nettmedia, Senior Developer
345 Seventh Ave., 24th Floor.
New York, NY 10001
Tel. 212.629.0004 x 131



--- Unsubscribe at http://nyphp.org/list/ ---









More information about the talk mailing list