0

hi experts,
always curious . why sometimes reference book use
simple quotation mark. sometime switch to double quotation mark. Does it matter in php?
e.g. define ('SQL_HOST','localahost');
however, in same define function i see double quotation in another source
define("CONSTANT", "Hello world.");

Thanks.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by fatcat2010
0

hi experts,
always curious . why sometimes reference book use
simple quotation mark. sometime switch to double quotation mark. Does it matter in php?
e.g. define ('SQL_HOST','localahost');
however, in same define function i see double quotation in another source
define("CONSTANT", "Hello world.");

Thanks.

Most of the time it does not make a difference. For example:

$a = "Hello world.";

is the same as

$a = 'Hello world.';

One main difference is that you can embed variables in double quotes, but you cannot in single quotes. For example:

print "The variable contains $a right now.";

Using single quotes you have to concatenate like so

print 'The variable contains '.$a.' right now.';

Also, PHP will interpret more escape sequences for special characters when enclosed in double quotes.

Some coders like to stick to double quotes, others prefer to use single quotes. That's why you see differences in quote styles across different scripts.

For more information, see http://www.php.net/manual/en/language.types.string.php

Edited by edwinhermann: n/a

0

thank you so much. you answered the questions hanging in my head for a long time. :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.