Php include?

limelight987

New Member
Messages
4
Reaction score
0
Points
0
I've never used php before but i read you could include headers and footers to all your pages so you can change your page's layout without changing each seperate page. Would this be a god idea and how would you do it?
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
Yes, it can be quite helpfull in a lot of cases.
First of all, your pages must have the .php extension, not .htm or .html
then just put your code in a file called "header.php" or something and where that code has to come, just put
PHP:
<?php include "header.php"; ?>

Warning: using a WYSIWYG-editor, you might get problems!
 

limelight987

New Member
Messages
4
Reaction score
0
Points
0
Yes, it can be quite helpfull in a lot of cases.
First of all, your pages must have the .php extension, not .htm or .html
then just put your code in a file called "header.php" or something and where that code has to come, just put
PHP:
<?php include "header.php"; ?>

Warning: using a WYSIWYG-editor, you might get problems!

Thanks it worked.
Hopefully it wil save me some time changing my layouts from now on.
Thanks again.
 
Last edited:

phpasks

New Member
Messages
145
Reaction score
0
Points
0
PHP:
<?php include("header.php"); ?>
<?php include_once("header.php"); ?>
<?php require("header.php"); ?>
<?php require_once("header.php"); ?>

The documentation below also applies to require(). The two constructs are identical in every way except how they handle failure. They both produce a Warning, but 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. Be warned that parse error in included file doesn't cause processing halting in PHP versions prior to PHP 4.3.5. Since this version, it does.

include_once() should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.


Also you can choose for include file above way.
 
Last edited:
Top