有好几种方法和函数供大家使用:
include()
include_once()
require()
require_once()
file_get_contents()
例如/例子:
// Create a DOM object from a string
$html = str_get_html('<html><body>Hello!</body></html>');
// Create a DOM object from a URL
$html = file_get_html('http://www.google.com/');
// Create a DOM object from a HTML file
$html = file_get_html('test.htm');
<?php
if(some condition)
{
//Dont allow access
}
else
{
include ("your_file.html");
}
?>
OR
<?php
if(some condition)
{
//Dont allow access
}
else
{
readfile("your_file.html");
}
?>
readfile
is faster and less memory intensive than file_get_contents
if(some condition) { //Dont allow access } else { echo file_get_contents("your_file.html"); }
OR
if(some condition) { //Dont allow access } else { require_once("your_file.html"); }