Optimizing PHP with the by using quotes properly in echo statements is a pretty easy
thing to do, and it will also enhance the security of your script ever-so-slightly.
Essentially, there are two types of quotes in PHP, double quotes ( “ ) and single quotes ( ‘ ). Both can be used in echo statements, but double-quotes have a lot more overhead since the interpreter must go through them looking for variables.
So, if you’re going to output a string that doesn’t have any variables you should always use single quotes.
Example:
1 2 3 4 5 | //This... (using single quotes) echo 'Hello World'; //is faster than this... (using double quotes) echo "Hellow World"; |
Its also slightly more secure since there’s no way a variable’s value can accidently be output in single quotes, but this is a minimal risk at best.
Categories
- Awards and Recognition (2)
- C# (2)
- GIS/Maps (1)
- Linux Admin (1)
- mySQL (4)
- Personal (2)
- PHP (6)
- SQL Server (1)
- The Business Side (2)
- Uncategorized (2)
- vbscript (1)
leave a reply
You must be logged in to post a comment.