views:

82

answers:

2

Can you tell me what is the different using (')single quotes inside (")quotes and (")quotes inside (')single quotes? and at concat, what is the meaning of this '".$bla."' I still can not distinguish them.

+3  A: 

In SQL, anything with single quotes is considered a text based data type.

SQL uses double quotes for escaping keywords and non-ASCII characters.

This:

'". $bla ."'

..is PHP syntax. $bla is a PHP variable, the period is a string concatenation character (which is why there's one on both sides). So in this example, the content of the $bla variable is being concatenated into a string, where it will be surrounded by single quotes.

OMG Ponies
thanks for a great lecture.
klox
+1  A: 

The main difference is the anything in a double quote is evaluated and anything in a single quote is not. There has been some discussion that it is better to use single quotes than double quotes so that PHP does not need to evaluate every aspect of the line to determine if it is a variable or not:

$good = 'really good';

echo "this is not $good"; //bad
echo 'this is' . $good;  //good

It just keeps thing running faster and keeps the code looking cleaner.

cdburgess