The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End [Solved] To use ‘ ‘ or ” “

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #30129

    Could someone please tell me when i should you single quotes and when to use double quotes. At the moments my code seems to vary depending on what my hands hits at the time.

    Chris Coyier

    In HTML and JavaScript it doesn’t matter, so long as your opening ones match your closing ones, and if you need to use one or the other inside, you alternate.

    In PHP, using double quotes allows you to use $variables inside the quotes, where single quotes do not.

    Rob MacKay

    Yea you just have to remember when using “” and vars that you don’t need to open array keys in ” – for example….

    echo "this is a string $array[key]"; 

    will work, as does

    echo 'this is a string ' . $array;

    But what is really good to use is curly brackets { }

    echo "this is a string {$array}";

    Then you don’t have to worry and you can use multidimensional key access with no headaches :D


    “multidimensional key access”

    Thank you neo! ;)

    Rob MacKay

    No problem – now I must away! Mr Smith is gathering!


    Thanks People.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Back End’ is closed to new topics and replies.