|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Include and Require
How many includes/requires should I limit myself too? I know that load time increases for each included file, but is there a general accepted rule about how many?
|
|
#2
|
|||
|
|||
|
there is not any rule when it comes to includes. just look at some of the larger/popular php programs, some probably have a hundred files being included and they can run in just a few milli-seconds.
|
|
#3
|
|||
|
|||
|
Limit yourself to the amount required. Think about your application design and flow. What is re-usable? Does that section of code really need to be an included file or will it only be used once?
Try to plan out your application before you start coding it in earnest. |
|
#4
|
|||
|
|||
|
As a general rule, includes and requires are your friends. There's no significant overhead, and if you plan out how you're going to use them, you can avoid reusing code in your apps. Here's the strategy I use:
You can require just one common file at the top of each page: PHP Code:
Then inside "common.inc.php" you can use PHP's __autoload function: PHP Code:
This will automatically load classes as you call them. It's a good way to have the code at your fingertips, without including code that you're not using. Then in your scripts, if you say: PHP Code:
You will automatically include a separate page with code for dealing with customers. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Programming Theory > Include and Require |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|