Echo ""; Or Print"";

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

    #31
    There is a difference between the two, but speed-wise it should be
    irrelevant which one you use. print() behaves like a function in that
    you can do: $ret = print "Hello World";And $ret will be 1That means
    that print can be used as part of a more complex expression where echo
    cannot. print is also part of the precedence table which it needs to
    be if it is to be used within a complex expression. It is just about at
    the bottom of the precendence list though. Only "," AND, OR and XOR
    are lower.echo is marginally faster since it doesn't set a return value
    if you really want to get down to the nitty gritty.If the grammar is:
    echo expression [, expression[, expression] ... ]Then echo (
    expression, expression ) is not valid. ( expression ) reduces to just
    an expression so this would be valid: echo ("howdy"),("partner");but
    you would simply write this as: echo "howdy","partner"; if you wanted
    to use two expression. Putting the brackets in there serves no purpose
    since there is no operator precendence issue with a single expression
    like that.
    [/b]

    copy paste from http://www.faqts.com/knowledge_base/...l/aid/1/fid/40
    http://ngeo.ro

    Comment


      #32
      pmpl blackhowk bro that was a cool one k:
      Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

      <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

      Comment


        #33
        lol use print ""; if u want to print text on some page, use echo ""; if u want to execute some code with text, use &#39;&#39;; tags if u want only one print/echo in page, i use it like that

        Comment


          #34
          Also note

          PHP Code:
          $string 'hello world';
          echo 
          '$string'
          will not work instead better use
          PHP Code:
          $string 'hello world';
              echo 
          ' '.$string.' '
          if you use echo or print is your own decision i personally like print most scripts use echo so i want to be different

          PHP Code:
          foreach ($_SERVER as $server => $value)
          {
          echo 
          "$server is $value<br />";

          Comment


            #35
            thats not true echo "$stuff"; works just not practical lol als o u can do this in links href=\"index.php?act=".$act['post']." can be href=\"index.php?act=$act[post]\" its lot neater theres no reason to wrap it in "

            Comment


              #36
              Its gud coding practise.
              This:
              echo '<a href="index.php">helo</a>';
              is alot neater.
              And so is this:
              echo "I am a {$foo} and you are a {$bar}.";

              Comment


                #37
                ori "$stuff" works lol but not '$stuff' and i somehow saw the board converted my code somehow

                PHP Code:
                foreach ($_SERVER as $server => $value)
                {
                echo 
                "$server is $value<br />";

                Comment


                  #38
                  echo is slightly faster..print only takes one parameter, while echo can have multiple parameters..print returns a value 1, so it can be used as a function..
                  My Blog: http://jhommark.blogspot.com
                  My Facebook: http://www.facebook.com/jhommark
                  My Official Site: http://www.undergroundweb.tk
                  My Community Site: http://undergroundwap.xtreemhost.com

                  Comment


                    #39
                    the speed of the two is negligable, you will NEVER use enough echo or prints to make the use of either noticeable. There is one main reason for the two, echo is not a function, this means it cannot be used inside another function as the callback whereas print can. I do say use echo as my own opinion as i prefer it but i wouldnt go spending hours changing it on your site, by the look of the code ive seen on this forum theres a hell of a lot more badly optimised code that would produce much better results if you fixed them.

                    but a few facts for you to chew on

                    echo is faster than print, its negligable but its there if you want to be perdantic. this is because print is a function/wrapper of echo

                    single quotes ' are faster than double quotes ", this is because when the interpreter sees a single code it will parse everything inside of those quotes as plaintext, double quotes allow variables to be used without the need to break out of the string delimiters therefore strings inside double quotes are scanned for variables to be exchanged.

                    Code:
                    $user = "djlee";
                    
                    echo 'welcome $user'; //prints welcome $user
                    
                    echo 'welcome'.$user; //prints welcome djlee
                    
                    echo "welcome $user"; //prints welcome djlee

                    Comment

                    Working...
                    X