Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

real simple question

Status
Not open for further replies.

tsp120

Programmer
May 21, 2003
52
US
I have some code in an HTML file that I would like to insert into a PHP file. I want to just include the file name of the HTML file, instead of copying and pasting the code into the PHP file. Basically I'm just looking for a way to include the contents of a file by simply calling the file name. I figure this must be really easy to do in either HTML or PHP, I just can't find out how when I look on the internet. Thanks for any help.
 
If what you are including, is *vital*, like a login system, then you should use require();

If what you are including, should only be included once, remember the _once, as in require_once(); (db information?).

If not, your other pages might try to redefine functions, which may then crash your script.

Also, Remember to check that the files are there, before trying to include them, by using the is_file().

if (is_file("foo.php")) {
require_once("foo.php");
}
else {
echo "<p><strong>A file is missing!</strong><br /> This may cause unwanted effects!</p>";
}

You can also make a function that wraps the include function..

function getFile($file, $method = "include") {
}

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top