Can You Give me some clarity...., Regarding Quotations

Discussion in 'PHP' started by actress143, Jun 5, 2010.

  1. #1
    i am very fresh to PHP...,

    in my journey i found some tedious situations..., i mean..

    some times i saw $_REQUEST['email'] ( single quotes )
    and in some sites... i saw $_REQUEST["email"] ( Double quotes )

    in the case of include("welcome.php") orrrrr include('welcome.php')


    ----- Single quotes or double quotes......, which is correct.., and give me some tip to remember where we have to use single quotes and double quotes..... -------

    Thanks a lot
     
    actress143, Jun 5, 2010 IP
  2. shubhamjain

    shubhamjain Active Member

    Messages:
    215
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    63
    #2
    Thats doesnt make any difference. PHP isnt like C/C++ where different qoutes have different meaning but in mysql_query(); statements, qoutes make some difference.
     
    shubhamjain, Jun 5, 2010 IP
  3. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #3
    ^^ no, there is always difference between the two, single quote is merely a string but double quote have to be evaluated by php if it contains variables in it.. like
    
    echo '$str is cool'; // would output: $str is cool
    $str = 'test';
    echo "$str is cool"; // would output: test is cool
    
    PHP:
     
    gapz101, Jun 5, 2010 IP
  4. HuggyEssex

    HuggyEssex Member

    Messages:
    297
    Likes Received:
    4
    Best Answers:
    2
    Trophy Points:
    45
    #4
    You should always pay attention to when you should use single or double quotes, helps to create a less resource hungry script.
     
    HuggyEssex, Jun 5, 2010 IP
  5. mehmetm

    mehmetm Well-Known Member

    Messages:
    134
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #5
    As far as I know, single quotes are just for using strings inside them.
    as gapz101 said, you can use variables within double quotes.

    so logically, php interpreter would look for any variable if you would use strings double quoted (resource usage).
    I suggest you that, if you don't need to put any variable within a string, just use the string single quoted.

    good luck :)
     
    mehmetm, Jun 5, 2010 IP
  6. actress143

    actress143 Peon

    Messages:
    132
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks for your replies friends, now i got the clarity on these..... quotes..

    thanks to alllll,
     
    actress143, Jun 5, 2010 IP