Jump to content

PHP performance


prkarpi

Recommended Posts

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.