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';
echo("$text");

echos Some Text. but

$text='Some Text';
echo('$text');

echos $text

Does that make ' more efficient than " ?

meth

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.