How to load an HTML file into an included PHP file from another PHP?
- by Peter NGM
i have 2 PHP file and 1 HTML.
i want to include file2.php in file1.php.
file1.php is:
<html>
<head>...</head>
<body>
...
<?php include("file2.php"); ?>
...
</body>
</html>
i want to load an HTML file in file2.php:
file2.php is:
<?php
$doc = new DOMDocument();
$doc->loadHTMLFile("sample.html");
echo $doc->saveHTML();
?>
and sample.html is:
...
<b>Hello World!</b>
...
my problem is this error:
Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: I/O
warning : failed to load external entity "sample.html" in
C:\xampp\htdocs\project\file2.php on line 3
please help me to solve this problem.