You are here: Re: [PHP] Echoing Variables Names « PHP « IT news, forums, messages
Re: [PHP] Echoing Variables Names

Posted by John Holmes on 01/18/05 06:28

Phillip S. Baker wrote:
> I am generating some variable variables.
> I am interested for testing purposes in finding out the names of the
> variables that are actually being generated. Since I want to make sure that
> that my following conditional statements are working properly and the values
> are set.
>
> So is there a way to print out the name of the variables?

I agree with the recommendation to just use an array. Variable variables
are almost always just a workaround for an array.

That being said, if you're creating the variable then you can create the
name. If you're saying

$a = 'x';
$b = 'y';
$c = 'z';
$xyz = 'foobar';

//Get name of "variable"
$name = $a.$b.$c; // $name = "xyz"

//Get value of variable
$value = ${$a.$b.$c}; // $value = "foobar"

Show some code if that doesn't clue you in.

--

---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

 

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

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