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.

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.