Including html document in php file

I am creating a web page which would be generated dynamically with the help of php. Within this file I want to show the contents (text only) of another file stored as an html file. I would like to know how would I be able
to open this  html file and show its content in a php generated web page using PHP.

The html text may be long containing about 100 - 500 lines.
qader99Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
maxkirConnect With a Mentor Commented:
Your php3 file:
<?php
// some your php3 code
require("included_html_filename.html");
// another your php3 code
?>
0
 
sghalebCommented:
Or if your include file contains only HTML (no PHP):

<?php
// some your php3_code
readfile("include_html_filename.html");
// another your php3 code
?>
0
 
Frank469Commented:
If your file is already formated in the way you want it posted to the browser the above require command would work, or you could use the include command which has basicly the same syntax:

     include("your_included_file");

When PHP includes your file it is treated as an html file unless tags are present in the included file that would indicate otherwise.

Also if you have common components that are displayed on each page - ie your banner, navigation items, and footers - it is easier to include these as seperate files or write them as functions to be included in a common functions file that can be included with every page.

If you have a table layout for the main display area of you page you might consider making a function where you could pass the names of the files for each section of the page instead of have to create the whole page just to have PHP redisplay it for you.
0
 
charlierokerCommented:
I am confused by this questions grade.  Why did the guy get a 'B'.  It is the perfect answer all be it not so tuff!  
0
All Courses

From novice to tech pro — start learning today.