You are here:
» Should You Use Single Or Double Quotes In Your PHP/Python Code?
Should you use single or double quotes in your PHP/Python code?
This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.
According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other?

1 year 43 weeks ago
Tags:
Personally I stick with one or the other. It doesn't matter.
Both would work but one may ask, so what is the big deal? why is it better?
Double Quotes way :
<?php
<?
Echo "<TABLE BORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"0\">";
?>
Single Quotes way :
<?php
<?
Echo '<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="0">';
?>
In this example you can see that we don't need to add escape characters for each Double Quote we want to echo as HTML.
This, by its self is a good enough reason to migrate, however, a 2nd reason is performance.
Using Single Quotes is always at least as fast as Double Quotes and in some cases faster by hundreds of percents.
I prefer single quotes because its only one keystroke instead of two. That is, I don't have to mash the shift key to make single quote.
Post Comment