|
-
Sep 2nd, 2011, 07:52 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Single Quote vs Double Quote, What to default to?
A single quote or string literal can be used in PHP to declare a String, ignoring all variables names inside. It may also contains a double quote inside of it. A double quote on the other hand - still declaring a String - accepts variable names to be passed inside, preventing the need for concatenation. A single quote also does not parse escape sequences such as \n and \r. Is there a performance difference between the two types of String Literals? Why not use a double quote all the time and simply escape other double quotes if they are required in the String. Besides outputting variable names I don't see the point in having two strings.
Personally I mostly use double quotes as my default choice when creating Strings unless I need to display a lot of text that contains quotations. In the latter case if there isn't much text I will escape the double quotations but otherwise I would just use single quotes.
I was just wondering if there was a reason (besides displaying variable names) for PHP to have multiple methods to declare a String.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|