Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Does <? include('x.php'); ?> have benefits?
Old 12-30-2008, 06:43 PM Does <? include('x.php'); ?> have benefits?
MoForce's Avatar
Super Talker

Posts: 145
Name: Jack Shalt
Trades: 0
Is it better to have one PHP file (index.php) that's some 800 lines long or is it better to have it broken down like

index.php
PHP Code:
<?php
include('a.php');
include(
'b.php');
include(
'c.php');
include(
'd.php');
include(
'e.php');
include(
'f.php');
include(
'g.php');
include(
'h.php');
Well what I'd really like to know is about speed... not about ease of editing later but loading speed and whatnot

Thanks
MoForce is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-30-2008, 06:51 PM Re: Does <? include('x.php'); ?> have benefits?
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
That will depend on what each script is doing.

ANSWER!!
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


Last edited by Decaf; 12-30-2008 at 10:25 PM..
Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 12-30-2008, 06:53 PM Re: Does <? include('x.php'); ?> have benefits?
stevej's Avatar
Professional Multitasker

Posts: 996
Location: Not positive
Trades: 0
It all depends on your needs and what kind of webpage you have, really.

- Steve
stevej is offline
Reply With Quote
View Public Profile
 
Old 12-30-2008, 07:21 PM Re: Does <? include('x.php'); ?> have benefits?
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
I'd say this is an interesting setup for a test.
It's probably really difficult to predict the result, if there is any difference at all.

I think a 800 line file would be quicker because of only one file being handled and the amount of executed and included code is still the same.
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 12-30-2008, 07:58 PM Re: Does <? include('x.php'); ?> have benefits?
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Breaking up your file into subparts is an organizational choice more than a performance one. I don't have any data to back this up but I'd say there is a slight performance advantage to having all of your code in one file. But I'd also say that that performance advantage is most likely negligable and is really a non-issue when it comes to organizing your code.

If you feel that the code is too cluttered you may want to break it up into logical chunks, each with its own file. You may want to put all of your function and class definitions in seperate files or put your header, footer, and body in seperate files.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 12-30-2008, 08:12 PM Re: Does <? include('x.php'); ?> have benefits?
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Quote:
Originally Posted by Insensus View Post
I'd say this is an interesting setup for a test.
It's probably really difficult to predict the result, if there is any difference at all.

I think a 800 line file would be quicker because of only one file being handled and the amount of executed and included code is still the same.
Loading Times in PHP
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 12-30-2008, 09:05 PM Re: Does <? include('x.php'); ?> have benefits?
Novice Talker

Posts: 7
Name: Alex
Trades: 0
If you need to include x.php in more than 1 page, then it's worth it. Because if you ever have to edit something in x.php, you edit 1 file instead of 10
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
effektz is offline
Reply With Quote
View Public Profile
 
Old 12-30-2008, 09:09 PM Re: Does <? include('x.php'); ?> have benefits?
MoForce's Avatar
Super Talker

Posts: 145
Name: Jack Shalt
Trades: 0
I guess we'll have to test it out =P ... I thought there might've been a definite answer on this one
MoForce is offline
Reply With Quote
View Public Profile
 
Old 12-30-2008, 09:49 PM Re: Does <? include('x.php'); ?> have benefits?
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Quote:
Originally Posted by effektz View Post
If you need to include x.php in more than 1 page, then it's worth it. Because if you ever have to edit something in x.php, you edit 1 file instead of 10
Your correct, I'm trying to get my clients to do this process.

Quote:
Originally Posted by MoForce View Post
I guess we'll have to test it out =P ... I thought there might've been a definite answer on this one
I really think that loading one file will be faster then loading 10, but we will test.

Edit: Working on testing here.

RESULTS!
The exact source of the pages is seen here.

oneFile | manyFiles
0.0004479885 | 0.0008339882
0.0002670288 | 0.0005609989
0.0004720688 | 0.0005619526
0.0004420280 | 0.0005569458
0.0002529621 | 0.0005500317

0.0002479553 | 0.0005619526
0.0002419949 | 0.0007579327
0.0004351139 | 0.0006299019
0.0002350807 | 0.0005540848
0.0002350807 | 0.0005538464

Conclusion: Loading one file is faster but only by a couple 10,000ths of a second. If your loading files that are many kb's though, one file will speed things up.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


Last edited by Decaf; 12-30-2008 at 10:23 PM..
Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 12-30-2008, 10:52 PM Re: Does <? include('x.php'); ?> have benefits?
MoForce's Avatar
Super Talker

Posts: 145
Name: Jack Shalt
Trades: 0
Quote:
Originally Posted by Decaf View Post
Conclusion: Loading one file is faster but only by a couple 10,000ths of a second. If your loading files that are many kb's though, one file will speed things up.
Awesome! Thanks for testing! Well I definitely like the results. Even though the file sizes were that small it still had an impact even though it's small. I wonder how much of a difference large files can make. Another test could help in creating an equation for load time differences. hmmm
MoForce is offline
Reply With Quote
View Public Profile
 
Old 12-30-2008, 10:55 PM Re: Does <? include('x.php'); ?> have benefits?
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Quote:
Originally Posted by MoForce View Post
Awesome! Thanks for testing! Well I definitely like the results. Even though the file sizes were that small it still had an impact even though it's small. I wonder how much of a difference large files can make. Another test could help in creating an equation for load time differences. hmmm
Well, check out the board.php script.

Edit, check out the "big_files" folder.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


Last edited by Decaf; 12-30-2008 at 10:56 PM..
Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 12-30-2008, 11:47 PM Re: Does <? include('x.php'); ?> have benefits?
MoForce's Avatar
Super Talker

Posts: 145
Name: Jack Shalt
Trades: 0
Quote:
Originally Posted by Decaf View Post
Well, check out the board.php script.

Edit, check out the "big_files" folder.
wow

The difference definitely gets bigger

Page loading took:0.0415828228 seconds (many files)
Page loading took:0.0105719566 seconds (one file)

a difference of a few 100ths of a second now
MoForce is offline
Reply With Quote
View Public Profile
 
Old 12-31-2008, 12:29 PM Re: Does <? include('x.php'); ?> have benefits?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
I really can't imagine that saving milliseconds for each user is a great benefit when you then have to waste untold hours editing dozens or hundreds of files when you change the wording of a link.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-01-2009, 03:46 PM Re: Does <? include('x.php'); ?> have benefits?
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Quote:
Originally Posted by chrishirst View Post
I really can't imagine that saving milliseconds for each user is a great benefit when you then have to waste untold hours editing dozens or hundreds of files when you change the wording of a link.
Can you give an example of having to edit so many links?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 01-01-2009, 05:01 PM Re: Does <? include('x.php'); ?> have benefits?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
If all of the pages are monolithic HTML documents, there isn't much of a choice but to edit every single page for every minor change.

Even if your pages are constructed with Dreamweaver templates the site has to be rebuilt and every page reuploaded.

Using includes, there is only one edit and one upload required to change any common feature.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?

Last edited by chrishirst; 01-01-2009 at 05:26 PM.. Reason: corrected my grammar
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-01-2009, 05:19 PM Re: Does <? include('x.php'); ?> have benefits?
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Quote:
Originally Posted by chrishirst View Post
If all of the pages are monolithic HTML documents, there isn't much of a choice but to edit every single page for every minor change.

Even if your pages are constructed with Dreamweaver templates the site has rebuilt and every page reuploaded.

Using includes, there is only one edit and one upload required to change any common feature.
Ya, i was thinking that you were saying something about having to change the include("page.php"); to include("page2.php");
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Reply     « Reply to Does <? include('x.php'); ?> have benefits?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.62566 seconds with 12 queries