Northern Flame Posted December 24, 2007 Share Posted December 24, 2007 i was just wondering if the number of lines in a PHP page affect the speed in which the page loads? Obviously, a script that does more will take longer to load, but do two scripts that do the exact same thing, yet are written differently have different loading times? And does white space matter on the script? Heres an example of what I am talking about: page1.php <?php /* blah blah blah blah blah blah */ $variable = 'test'; if($variable == 'testing'){ echo $variable; } elseif($variable == 'test'){ echo $variable; } else{ echo 'hello'; } ?> page2.php <?php /* comments */ $variable = 'test'; switch($variable){ case 'testing' || 'test': echo $variable; break; default: echo 'hello'; break; } ?> obviously those scripts do nothing but echo test, but if it was a larger script and they were written somewhat the same, would the loading times be noticeably different? P.S. if anyone is wondering why I am asking this question is because there are a few websites I coded back that have a lot of white space and can be shortened such as page1.php and now I have gotten better at PHP and can re-code them to shorten them like page2.php and I am wondering if it is worth doing. Quote Link to comment https://forums.phpfreaks.com/topic/83027-solved-speed-of-loading-a-php-page/ Share on other sites More sharing options...
asmith Posted December 24, 2007 Share Posted December 24, 2007 take a look at this : (similar to what you are asking) http://www.phpfreaks.com/forums/index.php/topic,173056.0.html Quote Link to comment https://forums.phpfreaks.com/topic/83027-solved-speed-of-loading-a-php-page/#findComment-422306 Share on other sites More sharing options...
roopurt18 Posted December 24, 2007 Share Posted December 24, 2007 The difference is negligible, don't waste your time. Quote Link to comment https://forums.phpfreaks.com/topic/83027-solved-speed-of-loading-a-php-page/#findComment-422308 Share on other sites More sharing options...
Northern Flame Posted December 24, 2007 Author Share Posted December 24, 2007 oh alright thanks for the replies Quote Link to comment https://forums.phpfreaks.com/topic/83027-solved-speed-of-loading-a-php-page/#findComment-422535 Share on other sites More sharing options...
corbin Posted December 24, 2007 Share Posted December 24, 2007 In that exact example, it would depend on whether PHP compiles swith or if statements more quickly.... Also, I'm not sure how quickly PHP gets rid of comments/white space when parsing, but I would imagine, it's extremely fast. Quote Link to comment https://forums.phpfreaks.com/topic/83027-solved-speed-of-loading-a-php-page/#findComment-422538 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.