RE: [PHP-DEV] PHP 4.0 Bug #8863: function to get constant values by variable name

From: Date: Tue, 23 Jan 2001 17:33:59 +0000
Subject: RE: [PHP-DEV] PHP 4.0 Bug #8863: function to get constant values by variable name
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-44838@lists.php.net to get a copy of this message
Not sure if this is exactly what you are after, but have you tried: $myvar = $$const_name; Sean > -----Original Message----- > From: andrew@andrew.org [mailto:andrew@andrew.org] > Sent: Tuesday, January 23, 2001 12:21 PM > To: php-dev@lists.php.net > Subject: [PHP-DEV] PHP 4.0 Bug #8863: function to get > constant values by > variable name > > > From: andrew@andrew.org > Operating system: Any > PHP version: 4.0.4pl1 > PHP Bug Type: Feature/Change Request > Bug description: function to get constant values by variable name > > I believe PHP lacks a function to get constant values by > name where the constant's name is stored in a string variable. > > What I mean is something like > > function get_constant($const_name) > { > eval ("\$myvar = " . $const_name . ";"); > return $myvar; > } > > but I really think that using eval() here is a waste. > > Am I missing something? > > andrew > > > -- > Edit Bug report at: http://bugs.php.net/?id=8863&edit=1 > > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > >

« previous php.dev (#44838) next »