Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: echo or var

  1. #1
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    echo or var

    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 " ?

  • #2
    Regular Coder meth's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Thanks
    0
    Thanked 9 Times in 9 Posts
    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.
    I do Web Design, Brisbane based.
    More time spent in PHP/MySQL Web Development.
    And Search Engine Optimisation takes up the rest of it.

  • #3
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for answering that !


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •