I'm using template pages for literally every page simply because it speeds up the opening of said files for working on them due to slow internet. And because my main page was over 1mil characters and analytics showed slow load times. After the change, it improved significantly. However, I'm unable to use var templates for any of my common snippets because of the quoted classes.
For example, being as I'm using Bootstrap, I'd like to place all the possible Glyphicons in one page so I don't have to type out the entire <span>
and just the variable.
$mail="<span class="glyphicon glyphicon-envelope"></span>";
$cart="<span class="glyphicon glyphicon-shopping-cart"></span>";
How can I allow the quoted classes inside the variable?
3 Possible options:
1- Either escape them \
:
$mail="<span class=\"glyphicon glyphicon-envelope\"></span>";
2- Use single quotes for the opening and closing quotes, or vice versa.
$mail='<span class="glyphicon glyphicon-envelope"></span>';
3- Or:
$mail="<span class='glyphicon glyphicon-envelope'></span>";
$mail="<span class='glyphicon glyphicon-envelope'></span>";
$cart="<span class='glyphicon glyphicon-shopping-cart'></span>";
or
$mail='<span class="glyphicon glyphicon-envelope"></span>';
$cart='<span class="glyphicon glyphicon-shopping-cart"></span>';
PHP allows the use of either single or double quotes, so you can simply use single quotes for the string here:
$mail='<span class="glyphicon glyphicon-envelope"></span>';
Note that single quotes and double quotes have slightly different behaviors in PHP, and there are also additional ways to define strings.