Announcement

Collapse
No announcement yet.

How Do _You_ Echo?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How Do _You_ Echo?

    What's your echo style?

    PHP Code:
    echo 'moo!'
    or

    PHP Code:
    echo ('moo!'); 
    "63,000 bugs in the code, 63,000 bugs, you get 1 whacked with a service pack, now there's 63,005 bugs in the code."
    "Before you critisize someone, walk a mile in their shoes. That way, when you critisize them, you're a mile away and you have their shoes."
    Utopia Software - Current Software: Utopia News Pro (news management system)

  • #2
    PHP Code:
    echo 'moo!'

    Comment


    • #3
      Is echo with the () even legal? echo isnt a function..

      Comment


      • #4
        Yeah. A bunch of people at Sitepoint use it, probably because Kevin Yank preached it that way in his book and they all developed a habit of it. =|
        "63,000 bugs in the code, 63,000 bugs, you get 1 whacked with a service pack, now there's 63,005 bugs in the code."
        "Before you critisize someone, walk a mile in their shoes. That way, when you critisize them, you're a mile away and you have their shoes."
        Utopia Software - Current Software: Utopia News Pro (news management system)

        Comment


        • #5
          echo "";

          I never use print(), i may use print_r sometimes, though.

          Comment


          • #6
            PHP Code:
            echo $var 
            and when there is more than one thing to be outputted:
            PHP Code:
            echo $var$var2$var3 
            I don't use echo very much though, as I have my template engine handle outputting content.

            Comment


            • #7
              echo is one of those whereby you can drop the parentheses so I just use echo ''; or echo ""; depending on what i'm outputting
              Dean Clatworthy - Web Developer/Designer

              Comment


              • #8
                Originally posted by CeleronXT
                Yeah. A bunch of people at Sitepoint use it, probably because Kevin Yank preached it that way in his book and they all developed a habit of it. =|
                Ah, I see

                Anyway, as to the origonal question.
                PHP Code:
                // one var
                 
                echo $var;
                 
                 
                // two+ vars
                 
                echo $var1$var2;
                 
                 
                // string
                 
                echo 'Hello World';
                 
                 
                // string w/ vars or control characters
                 
                echo "Hello $world \n";
                 
                // though I find myself in a habit of putting curlies around the variable
                 
                echo "Hello {$world}\n";
                 
                // thats not bad, is it?! 

                Comment


                • #9
                  Depends on what im using, if im echoing a variable, then i'll use

                  PHP Code:
                  echo $somevar
                  but more complex stuff i'll use

                  PHP Code:
                  echo ("hello <a href=\"mooooo.html\">sup</a>"); 

                  Comment


                  • #10
                    // thats not bad, is it?!

                    Nope!

                    Comment


                    • #11
                      Originally posted by Cyborg from DH
                      // thats not bad, is it?!

                      Nope!
                      Phew! I meant, does it slow down the parsing or sumthin..

                      Comment


                      • #12
                        Nope, it wouldn't be any slower than not using them

                        Comment


                        • #13
                          Wrong
                          "" is slower than ''
                          Especialy if you have a dollar sign in it
                          echo "This is extremly $ slow!!"

                          echo 'Hello '.$world.'
                          ';
                          Is faster than:
                          echo "Hello $world \n";

                          Edit: Even faster with a comma instead of the dot
                          Last edited by Daijoubu; Tue 16 Sep '03, 7:49pm.

                          Comment


                          • #14
                            well if we're going to talk about speed
                            PHP Code:
                            echo 'Hello'$world
                            is faster than
                            PHP Code:
                            echo 'Hello' $world
                            But he was asking if using "Hello {$world}" was slower than "Hello $world", which it's not.

                            Comment


                            • #15
                              Right with or without {} are the same

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...
                              X