I have the header.php which has the basic logic applying to all php files inside web root folder.
Let’s suppose I have the following 5 pages “index.php, post.php, list.page, read.page, update.page” in the folder.
Index.php begins with <?php include “header.php” ?> .
post.php begins with <?php include “header.php” ?> .
list.php begins with <?php include “header.php” ?> .
read.php begins with <?php include “header.php” ?> .
update.php begins with <?php include “header.php” ?> .
All php files in the folder begins with <?php include “header.php” ?> .
I doubt why I should put the code “<?php include “header.php” ?>” in all php files in the folder.
I’ll be happy if all php files in the folder has the code of header.php automatically without the code <?php include “header.php” ?>.
coldFusion has this kind of function.
The file of the name is “application.cfm”
When a user open any coldFusion(cfm) files in a folder,
coldFusion server searchs application.cfm in the folder before it reads the requested cfm files.
If application.cfm is in the folder, it reads application.cfm first and reads the requested cfm file.
If application.cfm is not in the folder, it reads the requested cfm file.
If a user calls application.cfm directly, it causes error.
Application.cfm is not a url file.
Application.cfm is included in the top of any cfm files without include code.
coldFusion developers usually put logic rather than display in the file of application.cfm
In my experience, it is very useful.
How about PHP?