Hi all,

OK. We all know that constants cannot be accessed directly via their name
in double-quoted or heredoc strings. I knew this already but a read of
the PHP manual got me thinking.

The manual states that to get the $$ value of a variable, the form
"{${var}}" should be used. Therefore, I wondered if something similar 
would work for constants.

Attempt 1 (just to be sure):
define ('XYZ','ABC');
echo "{XYZ}\n";

Output - {XYZ}

Attempt 2:
define ('XYZ','ABC');
echo "{{XYZ}}\n";

Output - {{XYZ}}

No luck there. I did encounter one oddity though:

define ('XYZ','ABC');
echo "{${XYZ}}\n";

PHP Notice: Undefined variable: ABC in /home/wilsond/testScripts/l7.php 
on line 3

Which appears to mean that PHP is able to pick up the value of the 
constant and try to access a variable with that name.

Any ideas?



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

Reply via email to