croakingtoad
10-10-2003, 11:27 PM
When you do an include statement, can you include another php file?
Like this:
include ("./main/body.php");
Like this:
include ("./main/body.php");
![]() | View Full Version : Easy PHP question croakingtoad 10-10-2003, 11:27 PM When you do an include statement, can you include another php file? Like this: include ("./main/body.php"); quasi 10-10-2003, 11:58 PM Yes you can, and PHP will automatically include its parsed output :) sponk 10-11-2003, 01:18 AM just to be sure when you do that, to have the correct include path. sergio 10-13-2003, 08:40 AM Yeah, also if you have multiple files with classes there is require_once function which will include each file only once so there will not be redeclarations of classes and functions because of multiple includes. Pavel 10-15-2003, 10:44 AM I recommand using require. include will not return a error if the file isnt found, require will matt2kjones 10-15-2003, 09:20 PM Originally posted by Pavel I recommand using require. include will not return a error if the file isnt found, require will it does doesn't it many of times i have seen scripts say that it couldn't include the file cos it doesn't exist. but still, require is nice Pavel 10-15-2003, 10:28 PM Actully your right, here is the quote from php/net http://php.us.themoes.org/include/ The documentation below also applies to require(). The two constructs are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error. In other words, use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless. Be sure to have an appropriate include_path setting as well. harmonic 10-15-2003, 10:33 PM try to use include_once(); though, or require_once(); Alan Wasser 10-16-2003, 11:40 AM you can include any file and it will automatically go in output |