PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
function one(){
print "This is the first section";
if (empty($_GET['var'])) {
print "no info here, sorry";} else {
print "$var is the info here";};
print "and so on and so on";
}
function two(){
print "This is the second section";
if (empty($_GET['var'])){
print "oops";} else {
print "$var is the info here";};
print "and so and so:;
}
it may be obvious, im just curious. iv been using readfiles and includes to keep the code clean and easy to work with. but im not sure if its going to be faster or slower in the long run doing it that way. if each section is say, 30-200 lines of code.
I'm not sure how the 'readfile' works but when you work with 'include', PHP actually replaces the 'include' statement with the full text in the include file.
It therefore doesn't improve your performance to use includes although it does make your files easier to read and more manageable.
I use the includes to add functions that are stored seperately to the pages.
to avoid looking in the include path? It seems to me that the include path will only be look at if the file is not found locally, so why do you do this
Just curious
edit:
Ok, after looking it up, include path is always used but ".;" or ".:" is usually inserted at the start of the path because " Using a . in the include path allows for relative includes as it means the current directory".
mm, i just wrote it as a quick example of the code to represent what i was doing. i keep most files that get included in a /includes/ directory. i use include() for things that are nessicary each and every time the page is loaded, and readfile() for information that only needs to be included sometimes (like in an if statement, or a function). the only files that remain in the same directory as the index file, are the things that get included every time the page is loaded (header information, and the layout of the page).
im not sure this is the proper way of doing this, but it is how iv been doing it thus far. i hope this clears it up