RE: [PHP] Constants in strings

From: Date: Wed, 06 Jul 2011 15:09:00 +0000
Subject: RE: [PHP] Constants in strings
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-313955@lists.php.net to get a copy of this message
> -----Original Message----- > From: Ashley Sheridan [mailto:ash@ashleysheridan.co.uk] > Sent: Wednesday, July 06, 2011 10:49 AM > To: admin@buskirkgraphics.com; 'Dave Wilson'; php-general@lists.php.net > Subject: RE: [PHP] Constants in strings > > > > > > >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. > > > > Except for when you're using heredoc, much like in the OPs first > post... > > Thanks, > Ash > http://www.ashleysheridan.co.uk > -- > Sent from my Android phone with K-9 Mail. Please excuse my brevity. Ash, I have a few questions. I use constants in my OOP and I never use the heredoc syntax. Now I am fearing that I have not taken advantage of something. My understanding of heredoc syntax as of 5.3 is just a string quoting right? Is there an advantage of using the heredoc syntax over single quoted or double quoted? Examples: Echo 'your constant for the javascript path is '.DIR_JAVA; Echo <<<EOT Your constant for the JavaScript path is {{DIR_JAVA}} EOT; I fully understand the syntax but I do not understand the advantages of using either. Is it just a writing style, or is there an advantage to the way it processes, speed or something?

« previous php.general (#313955) next »