--- micro brew <[EMAIL PROTECTED]> wrote:
> Could somebody please explain to me the difference
> between single quotes and double quotes in PHP.

Strings within single quotes are not evaluated. String within double quotes
are. Try this example:

<?
$foo = 'bar';

echo '$foo';
echo "$foo";
echo $foo;

echo 'bar';
echo "bar";
?>

If there is nothing to be evaluated (such as a variable), as is the case in the
last two examples, you will notice no difference.

Also, because single quotes within a string must be escaped when single quotes
are the delimiter, and vice versa, it is sometimes convenient to choose based
on that alone. For example:

$sql = "select foo from bar where blah='whatever'";

instead of:

$sql = 'select foo from bar where blah=\'whatever\'';

or:

echo '<a href="http://www.php.net/";>PHP</a>';

instead of:

echo "<a href=\"http://www.php.net/\";>PHP</a>";

Hope that helps.

Chris

=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to