Yeah, that was my answer and I was rebuked for that. admin@xxxxxxxxxxxxxxxxxxx wrote: >> -----Original Message----- >> From: Dave Wilson [mailto:dai_bach24@xxxxxxxxxxx] >> Sent: Wednesday, July 06, 2011 10:11 AM >> To: php-general@xxxxxxxxxxxxx >> Subject: Re: Constants in strings >> >> On Wed, 06 Jul 2011 12:56:21 +0100, Stuart Dallas wrote: >> > My guess is that the preceding $ causes PHP to interpret the next >> token >> > "{XYZ}" as a variable or a constant, but without that preceding $ it >> has >> > no way to know you're trying to use a constant. As Curtis points out, >> > the only way to insert a constant into a string is through >> > concatenation. >> > >> > -Stuart >> >> OK. I should have made myself clearer - I was making an observation >> with >> regards to constant parsing in strings rather than looking for advice. >> My >> bad. >> >> My third example showed that "{${XYZ}}" would echo the value of the >> variable called the value of XYZ: >> <?php >> define ('XYZ','ABC'); >> >> $ABC="huh!"; >> >> echo "{${XYZ}}\n"; >> ?> >> Output - huh! >> >> We could easily re-write the 'echo' line above to be: >> echo "{${constant('XYZ'}}\n"; >> >> But my example shows that PHP *is* accessing the value of a constant >> without any jiggery-pokery or hacks (e.g. http://www.php.net/manual/en/ >> language.types.string.php#91628) as it is retrieving the value of ABC >> from the XYZ constant and then looking for a variable of that name. >> >> I admit that I'm no C coder but it may be possible (note, the word >> "may") >> that a change of code within the PHP source tree will allow us to use >> something like echo "{{XYZ}}" to access the constant value. >> >> Cheers >> >> Dave >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php > > > > define('DIR_JAVA', '/js/'); > > When you need to use the JavaScript directory you can do this. > <script src="<?php echo DIR_JAVA . 'jquery-1.5.1.js';?>"></script> > > There is no true need for the curly brackets to echo out the value of the > constant. > > > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >