Re: Echoing Variables Names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux