Click to See Complete Forum and Search --> : In Need Of A Script


Jick
08-11-2003, 09:12 PM
I'm in need of a script that will automaticly insert a peice of code that I specify into all of my pages! I have a site that I'm working on and it has alot of pages and I need to be able to have it insert a little peice of php code into the tops of all of my files so I don't have to do it manuelly. I don't want to have to go and insert it in every page and then change it every time if I need to change the code. Is there a script that will do this? Thanks. :D

metrosoccer12
08-11-2003, 09:15 PM
cant u make a .js file and get it to load in each page?

pyro
08-11-2003, 10:36 PM
You could, but what are the 13% of users who do not use javascript going to get? Nothing at all...

Here's that PHP to include a file:
<?PHP
include ("file.php");
?>

brendandonhue
08-11-2003, 11:20 PM
And if the code is absolutely required for every page, use
<?php
require("file.php");
?>

pyro
08-11-2003, 11:23 PM
They are almost identical... The only difference is in how they handel errors:

From http://us2.php.net/manual/en/function.include.php
The two constructs are identical in every way except how they handle failure. include() produces a Warning while 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.