|
PHP Tutorial Home
Basic PHPPHP IntroductionPHP Installation PHP Syntax PHP Variables PHP Form Variables PHP If Statements PHP Switch Statements PHP Arrays PHP While Loops PHP For Loops PHP Operators PHP Functions Advanced PHPPHP IncludePHP Upload File PHP File PHP Mail PHP Mail Configuration PHP Database Driven Website PHP Summary FREE Hosting!With every domain name you register with ZappyHost, you get FREE hosting.$1.99 Domain NamesWith every new non-domain purchase thru ZappyHost, you get a domain name for only $1.99. |
PHP IncludeA PHP "Include" is a file that is included into another file. This concept allows you to re-use content throughout your website. For example, you could have a standard header and footer on every page of your website. Instead of copying/pasting this code on to every page, you could simply place your header code into one include file and your footer code into another include file. Then, on every page, all you need to do is refer to the header and footer include files. You can do this either using the include() function or the require() function. There's only a small difference between the include function and the require function. More on that below. The include() FunctionTo include a file using the include() function, you simply call the function (as you would any other function) and insert the file path as a parameter. Usage Example
The require() FunctionUsage of the require() function is exactly the same as the include() function - simply call the function and pass the path of the include file. The difference between the include() and require() functions is in the way they handle errors. If the included file can't be located, the include() function will still display the rest of the page (as well as an error). The require() function, on the other hand, will simply display an error - it won't display the rest of the page. Usage Example
Enjoy this website?
Oh, and thank you for supporting Quackit! |
Need Content for your Website?Get unique, quality digital content for your website. You can even earn money by reselling it!Includes:
|