Jump to content

Recommended Posts

Dear Forum,

 

which of the following lines is the more efficient one, regarding parsing time? Or are they all the same?

 

(1) $string = $a.' > '.$b.' > '.$c.' > '.$d;
(2) $string = "$a > $b > $c > $d";

 

I've done some benchmark tests to find out that the second one is only slightly more efficient - can you confirm that?

In which cases would you prefer the first method?

 

Link to comment
https://forums.phpfreaks.com/topic/119451-code-optimization-issue/
Share on other sites

Why is speed an issue with such a code example?

There are loads of methods for constructing a string as above, implode(), sprintf(), printf() are some functions that could do it?

Are you running PHP on a 286 pc?

 

In large scale, high traffic scripts, milliseconds make a huge difference. Nothing wrong with attempting to make a script as efficient as possible.

Ok. Thanks for your proposals. I don't have any experience with Zend and I can't say whether it would help in this issue -- however, I will give it a try. The thing is that my script can produce a different result every time, as it depends a lot on user input. It is an evaluation script that works for a number of different forms. Then, the script is meant to work on environments where developers do not always have the option to install optimizers on their servers on their own.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.