Gayner Posted August 12, 2009 Share Posted August 12, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/169909-one-line-speed-up-php/ Share on other sites More sharing options...
JonnoTheDev Posted August 12, 2009 Share Posted August 12, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/169909-one-line-speed-up-php/#findComment-896340 Share on other sites More sharing options...
wildteen88 Posted August 12, 2009 Share Posted August 12, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/169909-one-line-speed-up-php/#findComment-896343 Share on other sites More sharing options...
br3nn4n Posted August 12, 2009 Share Posted August 12, 2009 "Syntax error on line 1" will have you pulling your hair out lol Quote Link to comment https://forums.phpfreaks.com/topic/169909-one-line-speed-up-php/#findComment-896370 Share on other sites More sharing options...
PFMaBiSmAd Posted August 12, 2009 Share Posted August 12, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/169909-one-line-speed-up-php/#findComment-896471 Share on other sites More sharing options...
Gayner Posted August 12, 2009 Author Share Posted August 12, 2009 Lol ic, so just a personal preference i guess but I'm never gonna do that I think I will stick to turney Operators right? LOL Quote Link to comment https://forums.phpfreaks.com/topic/169909-one-line-speed-up-php/#findComment-896510 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.