Announcement

Collapse
No announcement yet.

How Do _You_ Echo?

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

  • #16
    I'm no expert, but there has to be some amount of time used to parse the two extra curley braces. At least a clock tick or two. So IMHO useing the braces would add time. We may not feel it, but be assured there is certainly more processing involved.
    Computer Help Forum
    An informed rider makes their first destination the motorcycle forum at rider info.

    Comment


    • #17
      Originally posted by Cyborg from DH
      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.
      ..and where is your proof? sorry to sound like i'm *****ing, i'd just like some proof.

      Comment


      • #18
        Originally posted by Cyborg from DH
        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.
        didn't know that, its quite interessting! so you never use any string-additions in echo-calls?
        so, which is faster? this:
        PHP Code:
        echo "<a href=\""$link"\" taget=\"_blank\">"$text"</a>"
        or this:
        PHP Code:
        echo "<a href=\"$link\" taget=\"_blank\">$text</a>"
        ?

        sorry for my bad english I hope, you understand me anyway

        Comment


        • #19
          How do I echo?

          Like this:

          PHP Code:
          <?php
           
          $cowsays 
          'Hello World';
           
          echo (
          moo($cowsays));
           
          function 
          moo($moo)
          {
              
          $moomoo = array();
           
              
          $moomoo['moo'] = $moo;
           
              foreach(
          $moomoo AS $moomoomoo => $moomoomoomoo
              {
                  if (
          $moomoomoomoo == $moomoomoomoo)
                  {
                      
          $moo $moo;
                  }
              }
           
              if (
          $moo == $moo)
              {
                  return 
          $moo;
              }
              elseif (
          $moo !== $moo)
              {
                  return 
          $moo;
              }
              else
              {
                  return 
          $moo;
              }
           
          //        (__)
          //        (oo)
          // /-------\/
          // / |     ||
          // * ||----||
          //   ~~    ~~ 

           
          // moo! ;)
           
          }
           
          ?>
          Sig? What sig?

          Comment


          • #20
            Originally posted by fiNal
            didn't know that, its quite interessting! so you never use any string-additions in echo-calls?
            so, which is faster? this:
            PHP Code:
            echo "<a href=\""$link"\" taget=\"_blank\">"$text"</a>"
            or this:
            PHP Code:
            echo "<a href=\"$link\" taget=\"_blank\">$text</a>"
            ?
            No idea...
            But
            PHP Code:
            echo '<a href="'$link'" taget="_blank">'$text'</a>'
            Is faster

            moo? Confusing eh

            Comment


            • #21
              and where is your proof? sorry to sound like i'm *****ing, i'd just like some proof.
              Proof that using commas is faster in echo, or proof that {$var} is the same speed as $var?

              Comment


              • #22
                Mooful.

                Comment


                • #23
                  Originally posted by Game Wizards
                  ..and where is your proof? sorry to sound like i'm *****ing, i'd just like some proof.
                  Well, i don't remember all the technical terms but that's only because my memory suxors

                  It's faster because using the . joins what ever is on the right to what's on the left, where as the comma doesn't. So, $var . $var2 . $var3 all get joined together as one big string then printed, but using $var, $var2, $var3 just prints each variable with no messing around

                  It's not like you ever know they were joined together though
                  Last edited by Babylon; Thu 18 Sep '03, 3:41am.

                  Comment


                  • #24
                    Originally posted by Cyborg from DH
                    Proof that using commas is faster in echo, or proof that {$var} is the same speed as $var?
                    Commas seen to be faster, that argument seems solid.

                    $var Vs. {$var}...

                    Since PHP is dynamically compiled/parsed it makes sense that there is more processing necessary to parse the extra two braces. A flag or something needs to be set and tracked to deal with the braces beginning and end. It may only be a couple of clock ticks, but more processing none the less. Even if we only compare reading 6 chars VS. 4 chars more work is necessary.
                    Computer Help Forum
                    An informed rider makes their first destination the motorcycle forum at rider info.

                    Comment


                    • #25
                      Originally posted by noppid
                      Commas seen to be faster, that argument seems solid.

                      $var Vs. {$var}...

                      Since PHP is dynamically compiled/parsed it makes sense that there is more processing necessary to parse the extra two braces. A flag or something needs to be set and tracked to deal with the braces beginning and end. It may only be a couple of clock ticks, but more processing none the less. Even if we only compare reading 6 chars VS. 4 chars more work is necessary.
                      So this would apply to nutscrape comments and ASCII cows then.
                      Sig? What sig?

                      Comment


                      • #26
                        Sure?

                        I've ran some tests using ab.exe with Apache 2.0.47 using PHP 4.3.3 installed on Win2k

                        Command: ab -n2000 -c1 -dS http://localhost/test.php
                        PHP Code:
                        <?php
                         
                         $test 
                        'test';
                         echo 
                        "This is a $test";
                         
                         
                        ?>
                        Fastest: 11.772 ms
                        Slowest: 11.992 ms
                        PHP Code:
                        <?php
                         
                         $test 
                        'test';
                         echo 
                        'This is a '.$test;
                         
                         
                        ?>
                        Fastest: 11.732 ms
                        Slowest: 11.982 ms
                        PHP Code:
                        <?php
                         
                         $test 
                        'test';
                         echo 
                        'This is a ',$test;
                         
                         
                        ?>
                        Fastest: 11.722 ms
                        Slowest: 11.982 ms

                        Sorry, but I can hardly see any difference.
                        Hints & Tips:
                        [[vB3] More Spiders / Indexers / Archives for vB3 - list]|[List of one-time-emails to ban]


                        http://sfx-images.mozilla.org/affili...efox_80x15.png

                        Comment


                        • #27
                          You'll get more precise result with a for () loop

                          Comment


                          • #28
                            yeah, run each like 500,000 times and average it.

                            Comment


                            • #29
                              Yes, you'll definitely need more lines in an echo if you're going to do it that way.
                              "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


                              • #30
                                Lookies
                                https://sourceforge.net/forum/forum....orum_id=236227

                                Comment

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