Jump to content

Recommended Posts

Try profiling it and find out!

 

Either way, I would guess the first would be quicker. But as they say, premature optimization is the root of all evil! Choose whatever is the easiest to read, I have a huge feeling that there will be bigger bottlenecks in your code than either of these.

Link to comment
https://forums.phpfreaks.com/topic/165970-witch-is-faster/#findComment-875355
Share on other sites

Quicker? You won't see a difference until you put this in a loop that is processing millions of entries. And even then, compared to the other parts of your code, the time it takes to process this is negligible.

 

But, I would go with the first because it uses 1 variable vs 4, and is cleaner code.

 

But then again, I would probably be using Smarty for my templates, which has an alternate method in it, so I wouldn't have this code at all :)

Link to comment
https://forums.phpfreaks.com/topic/165970-witch-is-faster/#findComment-875361
Share on other sites

Quicker? You won't see a difference until you put this in a loop that is processing millions of entries. And even then, compared to the other parts of your code, the time it takes to process this is negligible.

 

But, I would go with the first because it uses 1 variable vs 4, and is cleaner code.

 

But then again, I would probably be using Smarty for my templates, which has an alternate method in it, so I wouldn't have this code at all :)

 

Smarty?

 

Im not trying to be mean ahah sorry

Link to comment
https://forums.phpfreaks.com/topic/165970-witch-is-faster/#findComment-875362
Share on other sites

Actually template engines are quite powerful and useful for separation of logic and presentation (as rhod said) in large projects. I tend to stick with the one baked into zend framework, but pretty much any template engines make a managing a large website much easier.

Link to comment
https://forums.phpfreaks.com/topic/165970-witch-is-faster/#findComment-875371
Share on other sites

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.