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

2001-01-23 Thread Sean R. Bright

Not sure if this is exactly what you are after, but have you tried:

$myvar = $$const_name;

Sean

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 23, 2001 12:21 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DEV] PHP 4.0 Bug #8863: function to get 
> constant values by
> variable name
> 
> 
> From: [EMAIL PROTECTED]
> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: 
> [EMAIL PROTECTED]
> 
> 

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




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

2001-01-23 Thread andrew

From: [EMAIL PROTECTED]
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 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]