prkarpi Posted September 26, 2008 Share Posted September 26, 2008 HI I am not a pro in PHP nor am I a newbie, but I want to ask a question. Is it better to build PHP scripts on one page and implement functions or have multiple pages without functions. What would perform better or faster and, which style is more secure? I have about 1000 or so lines of code implemented with HTML. Thanks for your attention. Regards. Link to comment https://forums.phpfreaks.com/topic/125877-php-performance/ Share on other sites More sharing options...
discomatt Posted September 26, 2008 Share Posted September 26, 2008 1000 lines of code on one page is disgusting to debug. Include functions as you need... or learn to program with Objects (OOP) and use an __autoload function... You'll never have to 'include' again I'm not saying it's wrong, it's just more difficult in the long run Link to comment https://forums.phpfreaks.com/topic/125877-php-performance/#findComment-650901 Share on other sites More sharing options...
redarrow Posted September 26, 2008 Share Posted September 26, 2008 i would add a fuction page include it............... Link to comment https://forums.phpfreaks.com/topic/125877-php-performance/#findComment-650905 Share on other sites More sharing options...
prkarpi Posted September 26, 2008 Author Share Posted September 26, 2008 1000 lines of code on one page is disgusting to debug. Include functions as you need... or learn to program with Objects (OOP) and use an __autoload function... You'll never have to 'include' again I'm not saying it's wrong, it's just more difficult in the long run I did not mention that I have functions built, and everything is built on one page with 1000 lines of php and html. Is it better to have functions on one page for simple retrieval of data from db, or have each page for its own functionality? -thanks. Link to comment https://forums.phpfreaks.com/topic/125877-php-performance/#findComment-650912 Share on other sites More sharing options...
redarrow Posted September 26, 2008 Share Posted September 26, 2008 All you need to do is have a page with function.php, and include the functions where needed........ There no reel sped diffrence code on one page just prefrence it looks better and easer to access... if you reall want to go the mile do oop Link to comment https://forums.phpfreaks.com/topic/125877-php-performance/#findComment-650918 Share on other sites More sharing options...
trq Posted September 26, 2008 Share Posted September 26, 2008 The difference in performance is minimal, not even worth worrying about, between having all your code in one page or many pages. The difference in ease of maintainence however is substantial when your code is broken up into organised chunks. Link to comment https://forums.phpfreaks.com/topic/125877-php-performance/#findComment-650919 Share on other sites More sharing options...
discomatt Posted September 26, 2008 Share Posted September 26, 2008 I did not mention that I have functions built, and everything is built on one page with 1000 lines of php and html. Is it better to have functions on one page for simple retrieval of data from db, or have each page for its own functionality? -thanks. It's even nice to bring larger if/then sections into their own files... instead of if ( $_GET['page'] == 'news' ) { # 200 lines of code here } You can use if ( $_GET['page'] == 'news' ) include( 'content/news.php' ); # PHP file with 200 lines of code in it Link to comment https://forums.phpfreaks.com/topic/125877-php-performance/#findComment-650924 Share on other sites More sharing options...
redarrow Posted September 26, 2008 Share Posted September 26, 2008 No use a switch not the if statement the switch is faster.................... Link to comment https://forums.phpfreaks.com/topic/125877-php-performance/#findComment-650955 Share on other sites More sharing options...
prkarpi Posted September 27, 2008 Author Share Posted September 27, 2008 Thanks to all of you. Link to comment https://forums.phpfreaks.com/topic/125877-php-performance/#findComment-651962 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.