I find myself utilising the double quotes often in my code.
I recently found out that everything inside double qoutes forces the interpreter to examine those contents to see if there are any variables and if it finds any, substitute them with their assigned values.. as opposed to single quotes, which just tells PHP to output whatever is in the single quotes without searching for variables.
If done frquently throughout your document, it makes the interpreter work harder then necessary, right? I am listing three versions of code below..
Version 1:
echo "<div class="div_thumbnailIllustBG">"; // using only double quotes...
Does this mean the enterpreter has to not only enterpret everything within the echo quotes, but also in the class quotes (sort of a double whammy)? In either case, this is bad coding practice, is it not?
So would this next version be more efficient?
Version 2:
echo "<div class='div_thumbnailIllustBG'>"; // using only double quotes for echo...single quotes for class...
This version is my what I am presently using (and sometimes, I also use version 1)
I assume then that the interpreter still evaluates everything inside the echo quotes for any variables right?.. but does this version mean I have shaved off some work for the interpreter by not including additional double quotes for the class aspect?
Version 3:
echo '<div class=\'div_thumbnailIllustBG\'>';
Am I right in understanding that this version would not involve the interpreter checking for any variables at all? Would that last version be the 'best' way to skim off any work from the interpreter in that respect?
Finally, is it worth going through all my code and changing as much as needed to single quotes? (keeping double quotes for variable interpretation).
Your thoughts and input is appreciated.
Cheers,
NRG