www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > PHP

    PHP Discussion and technical support for using and deploying PHP based websites.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 03-26-2006, 10:30 PM
    Kyleva2204's Avatar
    Kyleva2204 Kyleva2204 is offline
    The One And Only
     
    Join Date: Jan 2003
    Location: VA
    Posts: 406
    ermm ' over "

    Ok, so I heard that you only use " when theres a variable involved, because it takes up time... other wise use '.. right? well.. what if you have \n?.. THe ' doesn't work with \n.. so should I use " or say 'this text.. + new line ' . "\n"; hm? This is probably a dumb question, but up until now, I thought I knew php pretty well, but it turns out theres much for me to learn, so thats why I'm asking.. I'm expecting that it wold be easier to use " because then it doesn't compute two different things..

    hehe thanks..
    Kyle
    __________________
    Cornflakes mmmm yummy
    Reply With Quote
      #2  
    Old 03-26-2006, 10:57 PM
    NogDog's Avatar
    NogDog NogDog is offline
    High Energy Magic Dept.
     
    Join Date: Aug 2004
    Location: Ankh-Morpork
    Posts: 14,007
    The time difference - if any - is so minimal that I wouldn't worry about it unless I were programming a mission-critical realtime system. And if I were doing that, I wouldn't be using PHP. (You're probably talking savings of a few milliseconds or even just microseconds, depending on the server where your code is running).

    Probably of much more importance 99.99% or so of the time is to keep your code as easy to read as possible by you, so that you can make changes at some later time with a minimum of agony.
    __________________
    "That's what the gods are! An answer that will do! Because there's food to be caught and babies to be born and life to be lived and so there is not time for big, complicated, and worrying answers! Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." -- from Nation, by Terry Pratchett
    freelancer.internet.com
    Email me
    Reply With Quote
      #3  
    Old 03-27-2006, 12:16 AM
    Kyleva2204's Avatar
    Kyleva2204 Kyleva2204 is offline
    The One And Only
     
    Join Date: Jan 2003
    Location: VA
    Posts: 406
    Hm- i was just reading some things online, and they are like ommeeegod save time!! >_<!!!! so yeah- just questioning it! :P
    __________________
    Cornflakes mmmm yummy
    Reply With Quote
      #4  
    Old 03-27-2006, 05:17 AM
    NogDog's Avatar
    NogDog NogDog is offline
    High Energy Magic Dept.
     
    Join Date: Aug 2004
    Location: Ankh-Morpork
    Posts: 14,007
    Try this little test, and refresh the page a few times (to account for random variations in processing time):
    PHP Code:
    <?php
    function microtime_float()
    {
      list(
    $usec, $sec) = explode(" ", microtime());
      return ((float)
    $usec + (float)$sec);
    }
    $time0 = microtime_float(); // "prime the pump"
    $time1 = microtime_float();
    echo
    '<p>This is a test.';
    echo
    'It is only a test.';
    echo
    'This is the end of the test</p>';
    $time2 = microtime_float();
    echo
    "<p>This is a test.";
    echo
    "It is only a test.";
    echo
    "This is the end of the test</p>";
    $time3 = microtime_float();
    echo <<<EOD
    <p>This is a test.
    It is only a test.
    This is the end of the test</p>
    EOD;$time4 = microtime_float();
    echo
    sprintf("<p>Test 1 took %f seconds</p>", $time2 - $time1);
    echo
    sprintf("<p>Test 2 took %f seconds</p>", $time3 - $time2);
    echo
    sprintf("<p>Test 3 took %f seconds</p>", $time4 - $time3);
    ?>
    Typical output on my PC was:
    Quote:
    Test 1 took 0.000050 seconds
    Test 2 took 0.000049 seconds
    Test 3 took 0.000056 seconds
    Hardly worth much worry about which is faster, I think?
    __________________
    "That's what the gods are! An answer that will do! Because there's food to be caught and babies to be born and life to be lived and so there is not time for big, complicated, and worrying answers! Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." -- from Nation, by Terry Pratchett
    freelancer.internet.com
    Email me
    Reply With Quote
      #5  
    Old 03-28-2006, 01:24 AM
    SpectreReturns SpectreReturns is offline
    Quite Uber
     
    Join Date: Feb 2005
    Location: BC, Canada
    Posts: 1,100
    I used to use ' but then I started C++ and C# and what not, so now I use " but don't use the variable parsing ability. (sorry, it seemed relevant when I typed it)
    __________________
    Corn is no place for a mighty warrior!
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 11:10 AM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.