This is what I like to call common sense.
|
|

More of an informational post.. not really a tutorial.
Hint: single quotes are faster but you need to concatenate variables
Example:
Output: i like dicksCode:$toAppend = 'dicks'; echo('i like '.$toAppend);
With double quotes you can do the above or just let PHP handle parsing it:
Output: i like dicks and dicksCode:$toAppend = 'dicks'; echo("i like ".$toAppend." and $toAppend");
Tip: as far as I know you need double quotes to use string literals (\r, \n, \t, \s, etc.). if you want a new line you can always use the PHP_EOL constant (cross-platform, bros!!!)
I don't really feel like elaborating on this subject but the difference is so minuscule, it doesn't even matter in most cases. It's a good habit to always use single quotes though. Double quotes when you absolutely need to or couldn't be fucked to optimize.
This is what I like to call common sense.
No, this is wrong. You are on the right track/idea but you have no clue what you are talking about.
-----
Single quotes run a lot faster because the computer is not attempting to execute your code when it doesn't need to.
Double quotes run slower because the computer is attempting to execute your code inside the quotes. Double quotes are similar to the eval PHP native function.
Single quotes run faster by like, nanoseconds.. The only reason that they're faster is because in double quotes PHP is checking for variables inside.
An example that you could do is:
Where as if you used single quotes you wouldn't be able to do that.$date = date("d M Y");
echo "Hello stranger, todays date is: $date";
Clear?

| « SilverTone Labs™ [BETA] | Follow Me With PHP? Doing well? Learn XHTML! » |
| Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |