ben: When to use " '?

I read a tutorial and sometimes the author is using ' - sometimes ".

What is the difference?

Example:

if(isset($_GET['section']) AND ("admin" == $_GET['section'])) {
session_start(); }

if(isset($_GET['section']) AND ('admin' == $_GET['section'])) {
session_start(); }

  1. Hi,

    What is the difference?

    the (number of) characters you have to escape. See the documentation.

    Cheatah

    --
    X-Self-Code: sh:( fo:} ch:~ rl:° br:> n4:& ie:% mo:) va:) de:] zu:) fl:{ ss:) ls:~ js:|
    X-Self-Code-Url: http://emmanuel.dammerer.at/selfcode.html
    X-Will-Answer-Email: No
    X-Please-Search-Archive-First: Absolutely Yes
  2. 你好 ben,

    I read a tutorial and sometimes the author is using ' - sometimes ".

    What is the difference?

    The difference is, that variables and escape sequences will not get expanded in single quotes. So,

      
    $var = "def"  
    echo "abc$var"  
    
    

    will print out abcdef, while

      
    $var = "def"  
    echo 'abc$var'  
    
    

    will print out abc$var. That's the main difference. For more information have a look at http://www.php.net/manual/en/language.types.string.php

    再见,
     克里斯蒂安