NYCPHP Meetup

NYPHP.org

[nycphp-talk] Output name of Variable

Jim Musil jim at nettmedia.com
Mon Feb 10 13:56:22 EST 2003


First off, this won't work because $number_of_rows is not declared inside
the function, but that's easily fixed.

Secondly, it seems like a silly way to do it. Why doesn't print_r() just
print the name of the variable? If it's sole purpose as a function is to
print out information about a variable, why not just print the name, too?

Obviously, I can and have worked around it for a long time. It just seems
like it should have been added over the years.


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




On 2/10/03 1:44 PM, "Chris Shiflett" <shiflett at php.net> wrote:

> --- Jim Musil <jim at nettmedia.com> wrote:
>> bug($number_of_rows);
>> 
>> And I wanted to have my output be
>> 
>> $number_of_rows: 5
> 
> 
> function bug($var_name)
> {
>  echo '$' . $var_name . ': ';
>  echo '<pre>';
>  print_r($$var_name);
>  echo '</pre>';
> }
> 
> bug('number_of_rows');
> 
> Chris
> 
> 
> --- Unsubscribe at http://nyphp.org/list/ ---
> 
> 




More information about the talk mailing list