View Full Version : echo or var

Michael B
12-27-2006, 01:25 PM
I would like to know if echoing text as it is created, or adding it to a variable then echoing it at the end of the script is more efficient?

Also I notice that when adding text to a var or echoing it, ' and " and different.

$text='Some Text';

echos Some Text. but

$text='Some Text';

echos $text

Does that make ' more efficient than " ?

12-27-2006, 02:58 PM
The only issue of where to output text concerns correct document structure. Output the text as valid html and everyone's happy. Any other aspect of data output is a matter of taste.

The difference between using single and double quotes is that php will treat everything inside single quotes as a literal string. When using double quotes, php will parse the string first then output the final data. Double quotes also require php to use more resources than singles.

Michael B
12-28-2006, 05:00 AM
Thanks for answering that !