View Full Version : Server-side includes in .php?
Flying Mullet
07-15-2005, 10:14 PM
Is there a way to do simple server-side includes in a .php file similar to <i><!--#include virtual="header.txt" --></i> in .shtml?
Endless
07-15-2005, 10:32 PM
include 'file.php';
or
require 'file.php';
In both cases it reads and executes the file, but include generates warnings in case of errors, whereas require generates fatal errors.
Flying Mullet
07-15-2005, 10:33 PM
Well now, let's not get too simple. :p
Thanks, I'll try it out.
Samuraid
07-15-2005, 10:42 PM
There is a difference between the two, although subtle...
include('file.txt') and require('file.txt') both include file.txt.
But if file.txt does not exist, require() will stop the php page execution, but include() only throws a warning and continues page execution.
Edit: oops, endless already said that...
Flying Mullet
07-15-2005, 10:44 PM
I've tried both and see what you both mean.
Ahh, so simple yet so effective. This is exactly what I needed. Thanks a lot. :)
Powered by vBulletin® Version 4.2.3 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.