Results 1 to 5 of 5

Thread: putting variables in quotes

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default putting variables in quotes

    which is better:
    Code:
    $ip=$db;
    or
    Code:
    $ip="$db";
    Last edited by james438; 03-30-2010 at 03:12 AM.
    To choose the lesser of two evils is still to choose evil. My personal site

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Could try processing it yourself http://blog.smileylover.com/calculat...imple-counter/ I'm not sure off hand and it seems hard to google
    Corrections to my coding/thoughts welcome.

  3. #3
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    I used the code you linked and found no difference.

    This is the best that I could find from php.net on the subject: http://www.php.net/manual/en/language.types.string.php
    To choose the lesser of two evils is still to choose evil. My personal site

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Never use extra steps when you don't need them-- it will take longer.

    $x="$y" is VERY inefficient because everything in the quotes must be parsed then converted to a string (from a string variable), then copied.
    $x=$y is just copying the value.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    makes sense, thanks.
    To choose the lesser of two evils is still to choose evil. My personal site

Bookmarks

Posting Permissions

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