Tip Details Add a Related Tip

Rate as: Positive Negative

Single versus double quotes in PHP

If you want to improve the performance of your PHP pages, always use single quotes for strings as opposed to double quotes. If you use double quotes, the interpreter has to parse the string to make substitutions as needed, and this is slower then just concatenating strings built up using single quotes. For example, use this:

$result = $x . ' + ' . $y . ' = ' . $z;

as opposed to:

$result = "$x + $y = $z";

The only time you really need to use double quotes is when you need to use interpreted characters, such as line feeds. But again, you can break the string into an interpreted section and a non-interpreted section to speed it up, like so:

$result = 'some string with a line feed on the end' . "\n";
Rating: no ratings, 0 total Votes
Categories: PHP coding programming
Added: on Mar 31, 2007 at 8:00 pm
Added By: Marcos84

Comments on this Tip

Add a Comment
There are no comments for this tip
Your Comment:
(how to format)
Rate This Tip:

Verify Humanity:
Sorry, we know it's annoying, but please enter the characters shown in the image to the left so that we know you're an actual person and not an evil spammer. Thanks.
       

Related Tips

How to Find a Random Date in PHP

33% positive, 0 comments
– Tip added by Walkere on Feb 07, 2008 at 8:25 pm

How to Syndicate an RSS Feed On Your Site

100% positive, 0 comments
– Tip added by Walkere on Feb 09, 2008 at 5:48 pm

How to Create a Random Password in PHP

100% positive, 0 comments
– Tip added by Walkere on Feb 03, 2008 at 9:14 am

Best PHP reference

Categories: PHP coding programming
100% positive, 0 comments
– Tip added by rlansky on Mar 07, 2007 at 2:38 pm

Referencing methods in PHP usort

Categories: php coding programming
no ratings, 0 comments
– Tip added by an anonymous user on Jun 13, 2008 at 11:18 am

A better way to paginate through results

100% positive, 2 comments - last added on Mar 09, 2007 at 7:27 am
– Tip added by tipstr on Mar 08, 2007 at 12:33 pm

Using functions in conditionals in Smarty

Categories: php programming Smarty web
100% positive, 3 comments - last added on May 21, 2008 at 1:36 pm
– Tip added by rlansky on Aug 10, 2007 at 1:02 pm

Something to consider before switching platforms

100% positive, 0 comments
– Tip added by an anonymous user on Sep 25, 2007 at 7:31 pm

Good code isn't always bad, it can always serve as a good example

66% positive, 0 comments
– Tip added by rlansky on Mar 07, 2007 at 6:29 am

Detecting if a variable exists in Javascript

100% positive, 0 comments
– Tip added by an anonymous user 2 days, 4 hours ago

Redirecting in PHP

100% positive, 0 comments
– Tip added by an anonymous user on Jul 17, 2008 at 7:27 am

compressing javascript

100% positive, 0 comments
– Tip added by an anonymous user on Jun 12, 2008 at 3:02 pm

Copyright date on sites

Categories: web programming php Smarty
100% positive, 0 comments
– Tip added by an anonymous user on Mar 11, 2008 at 8:14 am

How to Send E-Mail in PHP: A “Share This” Form

50% positive, 0 comments
– Tip added by Walkere on Feb 06, 2008 at 6:45 pm

Quick UML reference

Categories: coding programming UML
100% positive, 0 comments
– Tip added by an anonymous user on Dec 24, 2007 at 8:52 am

Answering a tricky interview question on swapping

100% positive, 1 comment - last added on Aug 20, 2007 at 8:55 am
– Tip added by an anonymous user on Aug 20, 2007 at 7:26 am

Best CVS book out there is available on-line... for free

Categories: CVS coding programming free
100% positive, 0 comments
– Tip added by Marcos84 on Mar 09, 2007 at 9:20 am

CakePHP: Working with Associations

no ratings, 0 comments
– Tip added by an anonymous user on May 08, 2008 at 4:09 am

Javascript: How to Create a Random Number

0% positive, 0 comments
– Tip added by Walkere on Feb 23, 2008 at 9:49 pm

File upload progress meters in PHP

Categories: programming web 2.0 php
no ratings, 0 comments
– Tip added by an anonymous user on Jun 16, 2007 at 5:03 pm