[PHP] constant from variable

2010-06-04 Thread Tanel Tammik
Hi,

define('MYCONST', 'something');

$my = 'my';
$const = 'const';


is it possible to get the value of MYCONST using variables $my and $const_

Br
Tanel 



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



RE: [PHP] constant from variable

2010-06-04 Thread Adam Petrone
Use the constant() function:

echo constant( $my . $const );

http://www.php.net/manual/en/function.constant.php

-Original Message-
From: Tanel Tammik [mailto:keevit...@gmail.com] 
Sent: Friday, June 04, 2010 3:08 PM
To: php-general@lists.php.net
Subject: [PHP] constant from variable

Hi,

define('MYCONST', 'something');

$my = 'my';
$const = 'const';


is it possible to get the value of MYCONST using variables $my and
$const_

Br
Tanel 



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


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



Re: [PHP] constant from variable

2010-06-04 Thread Ashley Sheridan
On Fri, 2010-06-04 at 22:07 +0300, Tanel Tammik wrote:

 Hi,
 
 define('MYCONST', 'something');
 
 $my = 'my';
 $const = 'const';
 
 
 is it possible to get the value of MYCONST using variables $my and $const_
 
 Br
 Tanel 
 
 
 


I don't really see how you can? The only correlation at all is that the
two variables use the same letters combined as their values as the name
of the constant but in a different case. Variables and constants in PHP
are case-sensitive.

Why are you trying to do this anyway? Perhaps there's a better way than
what you are trying to do.

Thanks,
Ash
http://www.ashleysheridan.co.uk