Jump to content

Recommended Posts

Random code but..

 

i have this line it's like this:

 

foreach( $final as $idx => $sess ){$inv    = '';if ( strstr( $sess['id'], '_session' ) ){$sess['is_bot'] = 1;if ( $ibforums->vars['spider_anon'] ){if ( $ibforums->member['mgroup'] == $ibforums->vars['admin_group'] ){$inv = '*';}else{continue;}}}else if ($sess['login_type'] == 1){if ( ($ibforums->member['mgroup'] == $ibforums->vars['admin_group']) and ($ibforums->vars['disable_admin_anon'] != 1) ){$inv = '*';}else{continue;}}$col_num++;
            

 

When i post the code it doesn't look good.. but on my site the line is just 1 big horizontal line..

is that faster for php to handle if it's like that or bad? or does it even matter? honestly.

           

 

I mean it works fine and cleaner on my editing page.. soo lol

Link to comment
https://forums.phpfreaks.com/topic/169909-one-line-speed-up-php/
Share on other sites

Good question.

The fact that it is simply unreadable / editable for a human puts a ? on your question.

I have never seen a server side script condensed in this way which makes me believe this is not an approach you would adopt. However client side scripts are a differet matter. I often see HTML, Javascript condensed to speed up their download to the client.

Having code on one line or multiple lines will have no affect on performance. The difference in speed will be extremely minimal. The end user wont be able to tell difference in page load times.

 

However the disadvantages you have with the code on one line are if there is any errors you wont be able to tell where they are as the code is unreadable.

You are going to waste about 3-5 orders of magnitude more time just putting code into that format and in maintaining and troubleshooting it than you will ever save in page generation time. The time you will save in page generating time would at most be a few hundred micro-seconds, which is in the ballpark of how long it takes to actually transmit just a few characters of your content to the browser (depending on connection type and speed.)

 

Plus if you ever need to get help on a programming forum, no one is going to read or help if you post code like that.

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.