PHP加载index.PHP时加载html文件
我试图显示一个php文件中的html文件。这是密码PHP加载index.PHP时加载html文件,php,html,Php,Html,我试图显示一个php文件中的html文件。这是密码 <?php public bool DOMDocument::loadHTMLFile ( string $cron.html [, int $options = 0 ] ); ?> 基本上,我想显示一个远程html文件,而不透露html文件的位置 首先,您将正式参数和实际参数弄乱了一点。 这是一个方法签名: public bool DOMDocument::loadHTMLFile ( string $filename [, i
<?php
public bool DOMDocument::loadHTMLFile ( string $cron.html [, int $options = 0 ] );
?>
基本上,我想显示一个远程html文件,而不透露html文件的位置 首先,您将正式参数和实际参数弄乱了一点。 这是一个方法签名:
public bool DOMDocument::loadHTMLFile ( string $filename [, int $options = 0 ] )
这就是你所说的:
$doc = new DOMDocument();
$doc->loadHTMLFile("cron.html");
echo $doc->saveHTML();
但是,在您的情况下,似乎没有必要将HTML文件的内容解析为结构化内容。只需将其转储到输出:
readfile('cron.html');
您还可以将文件内容读入字符串变量:
$content = file_get_contents('cron.html');
它也适用于远程文件:
// Create a stream
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n"
)
);
$context = stream_context_create($opts);
// Open the file using the HTTP headers set above
$file = file_get_contents('http://www.example.com/', false, $context);
源代码示例:。首先,您将形式参数和实际参数弄乱了一点。 这是一个方法签名:
public bool DOMDocument::loadHTMLFile ( string $filename [, int $options = 0 ] )
这就是你所说的:
$doc = new DOMDocument();
$doc->loadHTMLFile("cron.html");
echo $doc->saveHTML();
但是,在您的情况下,似乎没有必要将HTML文件的内容解析为结构化内容。只需将其转储到输出:
readfile('cron.html');
您还可以将文件内容读入字符串变量:
$content = file_get_contents('cron.html');
它也适用于远程文件:
// Create a stream
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n"
)
);
$context = stream_context_create($opts);
// Open the file using the HTTP headers set above
$file = file_get_contents('http://www.example.com/', false, $context);
代码源示例:。这对您有用吗
<?
$location = "somelocation/file.htlml";
include($location);
?>
这对你有用吗
<?
$location = "somelocation/file.htlml";
include($location);
?>
为什么不直接使用include函数呢? 包括和/或包括_一次;或require->require;和/或要求_一次
希望有帮助 为什么不直接使用include函数呢? 包括和/或包括_一次;或require->require;和/或要求_一次 希望有帮助 您可以使用。以下是PHP文档中的一个官方示例:
<?php
$homepage = file_get_contents('http://www.example.com/');
echo $homepage;
?>
你可以用。以下是PHP文档中的一个官方示例:
<?php
$homepage = file_get_contents('http://www.example.com/');
echo $homepage;
?>
有什么问题吗?有什么问题吗?在一些类似的情况下,我认为文件内容是一种魔力。别忘了+1。在一些类似的情况下,我认为文件内容是一种魔力。别忘了+1。