LOL! True that! Guess it depends on the situation.Ambush Commander wrote:But it's annoying when you're writing a sentence.
Parse error! ARGH!Code: Select all
$string = 'But it's annoying when you're writing a sentence.';
difference between ' and "?
Moderator: General Moderators
Code: Select all
$string = 'But it\'s annoying when you\'re trying to write a sentence!';I use single quotes, doubles if I need a variable parsed inline.
Using doubles unecessarily (i.e. on a literal/static string) is less efficient than single quotes.
Why?
Single quotes says to PHP: "Here, take this value as it is."
Doubles say: "Read through me first, and check if there are any variables that need parsing and replacing."
IMO singles are better than doubles
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Maybe the ultimate quote is a backslash... almost never used, and when used, well, you'd have to escape it anyway. Don't know how the lexer would make sense of it though.
Edit - as to your reply, ideally, we wouldn't have to escape anything at all. I hate writing a string, firing up PHP, discovering a parse error, then remembering that I had forgotten to escape my quotes. It's really annoying.
Edit - as to your reply, ideally, we wouldn't have to escape anything at all. I hate writing a string, firing up PHP, discovering a parse error, then remembering that I had forgotten to escape my quotes. It's really annoying.
use blocks then 
You can change BLOCK for any phrase/char you like.
Code: Select all
$str = <<<BLOCK
BOO!
BLOCK;- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- Buddha443556
- Forum Regular
- Posts: 873
- Joined: Fri Mar 19, 2004 1:51 pm
lol, yeah indeed. I tend to not really bother too much with double or single quotes, it's usually single quotes. I find enough else in my code to optimise, simplifying logic being the number #1 thing. It's always amazing how much you can optimise when you refactor your code after a couple of months.Buddha443556 wrote:As much as an optimization nut as I am, I still regard this as code standardizarion issue. Just be consistant.
Can't believe this topic got two pages!WTG Method Man!