RE: Constants in strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Ashley Sheridan [mailto:ash@xxxxxxxxxxxxxxxxxxxx]
> Sent: Wednesday, July 06, 2011 10:49 AM
> To: admin@xxxxxxxxxxxxxxxxxxx; 'Dave Wilson'; php-general@xxxxxxxxxxxxx
> Subject: RE:  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?





 


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




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux