Jump to content

Recommended Posts

To be safe, you should put your $_GET variable in curly braces to ensure it's handled correctly, like so:

 

$url = "http://www.site.com/soccer/{$_GET['league']}";

Why not just use? :

$url = 'http://www.site.com/soccer/'.$_GET['league'];

 

A lot cleaner, simpler and a bit faster.

I find that if i start with this

$url = 'http://www.site.com/soccer/'.$_GET['league'];

this takes me longer

$Domin = "site.com";
$Section = "soccer";
$url = 'http://www.'.$Domin.'/'.$Section.'/'.$_GET['league'];

 

than if i start with this

$url = "http://www.site.com/soccer/{$_GET['league']}";

and update do this

$Domin = "site.com";
$Section = "soccer";
$url = "http://www.$Domin/$Section/{$_GET['league']}";
//or
$url = "http://www.{$Domin}/{$Section}/{$_GET['league']}";

 

and I find it slightly easier to read!

 

but with any micro optimization it normally depends on the personal preference.

My Logic is simple, if its a hundredth of a second faster at run time but takes 2 seconds longer to read a design time I'll probably not worry about the hundredth  of a second.

Ok ok, sorry for making you mad!

It's just that I didn't understand your logic, and your'e right depends if the person is a speed freak or not.

 

but you have to agree that if it's a giant slow application so then you would try to make it faster with these things.

Ok ok, sorry for making you mad!

It's just that I didn't understand your logic, and your'e right depends if the person is a speed freak or not.

 

but you have to agree that if it's a giant slow application so then you would try to make it faster with these things.

 

I don't think that MT is mad.

 

Also, if my app is running slowly, looking at how my output was interpolating variables would be one of the last steps I'd take, simply because there are other things that would be the likely source of the slowdown. 

 

Not saying that you wouldn't, either, it's just that there's a common meme with some users on here where they think that code optimization (which shouldn't be a priority until the late stages of a project) consists simply of fiddling around with how output strings are quoted and concatenated because some book or tutorial mentions that one way of doing it is 'faster' (hundredth's of a second, if that) than another.  All while they have nested loops running amok everywhere.

 

Again, not lumping you, specifically, in that group.  Just figured I'd comment on a general trend I've seen in order to help curb things in the right direction.

Sorry if I appeared mad, that was not my intent,

 

I just find if I have a lot of HTML in 1 of more variables I know I'm probably going to update it later, so I use the logic of single quotes for strict and double quotes for dynamic, for the whole variable. then I just have to remember to escape the double quotes,

for example in

$_GET['league']

league is strict (won't change) but

$_GET["league{$x}s"]

is dynamic and LOOK's cleaner (to me)

instead of

$_GET['league'.$x.'s']

 

as I said it's down to personal preference really.

 

Oh and I maybe mistaken but I believe the biggest difference in speed was in PHP4 but was optimised in PHP5.

in a loop of 10,000 the difference was 0.03 seconds

EDIT: that's

$url = 'http://www.site.com/soccer/'.$_GET['league'];

winning by 0.03 seconds

Your'e right that there are other things that slow down a lot more than using single-quote instead of double-quotes.

And for me speed always comes first but that doesn't means that I'm going to write all of my code in one line so it will be "faster", I'm going to write it in a way that I can easily understand it, and the architecture of the app is a lot more crucial than a hundredth's of a second.

 

But in apps that need to run the fastest and are loading in 200ms so cutting it down to 150ms counts a lot, one day I'll post loading times of my online OS(an app where speed counts) with small optimisations and small ones and I'm sure there would be a big difference.

 

And your'e right I think $_GET["league{$x}s"] is a lot cleaner, maybe working too much on a speedy app has made me blind. lol

 

well I think I have pulled away from the subject(which is already solved) too much.

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.