PHP include
From Wiki @ Karl Jones dot com
Revision as of 19:09, 20 September 2016 by Karl Jones (Talk | contribs)
In PHP, the include and require keywords copies the contents of one file into other file.
This is useful for making a file (such as the header section of a web page) which is included into many web pages.
include is optional: if the specified file does not exist, PHP ignores the include.
require is not optional: if the specified file does not exist, PHP generates an error.
Example
Here is a PHP page named message.php
, which contains some text.
Hello World!
Here is a PHP page named some-page.php
:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>HTML 5 example: minimum required elements</title> </head> <body> <?php include message.php; ?> </body> </html>
In the above example, some-page.php
includes the Hello World! text.
See also
External links
- PHP include @ php.net
- PHP include files @ w3schools.com