random1 Posted April 20, 2008 Share Posted April 20, 2008 Hey All, I'm looking for effective methods of optimizing pages. i.e. What are the actions that should take place on page load and on page exit? * Garbage collection * unsetting of variables * Clearing of objects from memory * Server Status etc? Quote Link to comment https://forums.phpfreaks.com/topic/101975-page-optimization/ Share on other sites More sharing options...
Daniel0 Posted April 20, 2008 Share Posted April 20, 2008 That'll be done for you automatically. Quote Link to comment https://forums.phpfreaks.com/topic/101975-page-optimization/#findComment-521871 Share on other sites More sharing options...
AP81 Posted April 20, 2008 Share Posted April 20, 2008 * Garbage Collection - PHP takes care of this, but putting __destruct methods in your classes will also help. * unsetting of variables - You should unset any arrays, particularly if they are large * Clearing of objects from memory - PHP will clean this up, but remember to do clean-ups in your destructor * Server side status - not sure what you would want to monitor here The bottom line: invest time into learning how to code well. Any idiot can write code in PHP, but not everyone can code efficiently. If you write code well, you shouldn't have to worry about the above. You can also look at using a PHP framework which will automate some of the above. Some frameworks also include page caching which will make your pages re-use database queries more effectively. Quote Link to comment https://forums.phpfreaks.com/topic/101975-page-optimization/#findComment-521876 Share on other sites More sharing options...
Fadion Posted April 20, 2008 Share Posted April 20, 2008 Any idiot can write code in PHP, but not everyone can code efficiently. That idiot may be me, you or alot others. If i cant write code efficiently, it means im an idiot? Anyone instead of any idiot could have been alot more appropriate. Quote Link to comment https://forums.phpfreaks.com/topic/101975-page-optimization/#findComment-521879 Share on other sites More sharing options...
IThinkMyBrainHurts Posted April 20, 2008 Share Posted April 20, 2008 When! Is not realising what you have not done an exscuse for being foolish? And yes there are ways of doing things, however there is always the most efficient, practical and safest way to do them! But hey we are here to learn and i've generally learnt the hard way, but at least I know why... Quote Link to comment https://forums.phpfreaks.com/topic/101975-page-optimization/#findComment-521884 Share on other sites More sharing options...
PFMaBiSmAd Posted April 20, 2008 Share Posted April 20, 2008 random1, there are many different forms of optimization - http://en.wikipedia.org/wiki/Optimization_(computer_science) You can optimize code to use fewer resources. You can optimize code to execute quicker. You can optimize code to be general purpose and independent of the type and amount of data it operates on. You can optimize code to be version/platform independent. Often these goals are mutually exclusive. You need to pick the one you want most. But optimizing code means to change what it is doing during its' execution. This has little to do with when a page loads (unless you are creating unnecessary variables/objects and your goal is to optimize resources) and it has nothing to do with what you do on a page exit in php as all resources used by a script are destroyed when the script ends (see Daniel0's post.) What you do to optimize any piece of code is dependent on what it is doing now (it might be as optimized as it can be) and on what optimization goal you are trying to achieve. Your question is fairly general. Do you have a specific problem that is occurring you are trying to solve? Since optimization is highly situational, it is not really possible to give a specific list of things to do unless you have a specific problem or goal and a specific piece of code you want help with. Quote Link to comment https://forums.phpfreaks.com/topic/101975-page-optimization/#findComment-521939 Share on other sites More sharing options...
GingerRobot Posted April 20, 2008 Share Posted April 20, 2008 Any idiot can write code in PHP, but not everyone can code efficiently. That idiot may be me, you or alot others. If i cant write code efficiently, it means im an idiot? Anyone instead of any idiot could have been alot more appropriate. Calm down. AP81's sentence doesn't actually imply that if you can't code efficiently then you are an idiot. Quote Link to comment https://forums.phpfreaks.com/topic/101975-page-optimization/#findComment-521947 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.