Client Portal
PHP include and require Statements
It is possible to insert the content of one PHP file into another PHP file (before the server executes it), with the include or require statement.
The include and require statements are identical, except upon failure:
require will produce a fatal error (E_COMPILE_ERROR) and stop or end of the script
include will only produce a warning (E_WARNING) and the script will continue
So, if you want the execution to go on and show users the output, even if the include file is missing, use the include statement. Otherwise, in case of FrameWork, CMS, or a complex PHP application coding, always use the require statement to include a key file to the flow of execution. This will help avoid compromising your application's security and integrity, just in-case one key file is accidentally missing.
Including files saves a lot of work. This means that you can create a standard header, footer, or menu file for all your web pages. Then, when the header needs to be updated, you can only update the header include file.
Citatoion on YouTube
Examples of PHP Include
include 'filename';
or for a PHP require which requires the full page to load.
require 'filename';
PHP Include Code Example
Hello World App!
Some example text.
Some more example text.
less than bracket ?php include 'footer1.php';? greater than bracket
BIO About the Author: Joseph P Fanning
Joe studied at Harvard. He owns Joepfanning.com and blogs alot about cool things and stuff. He co owns Business Process Automation
Phone - 201 334 8743
Email - Joe's App email
Suffolk County LI New York 11772 Bergen County NJ Programmer