나는 2 개의 PHP 파일과 1 개의 HTML을 가지고있다.다른 PHP에서 포함 된 PHP 파일에 HTML 파일을로드하는 방법은 무엇입니까?
file1.php에 file2.php를 포함시키고 싶습니다.
file1.php은 다음과 같습니다
<?php
$doc = new DOMDocument();
$doc->loadHTMLFile("sample.html");
echo $doc->saveHTML();
?>
및 sample.html은 다음과 같습니다
file2.php은 다음과 같습니다
<html>
<head>...</head>
<body>
...
<?php include("file2.php"); ?>
...
</body>
</html>
내가 file2.php에 HTML 파일을로드 할 :
...
<b>Hello World!</b>
...
내 문제는 이쪽입니다. 오류 :
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
이 문제를 해결하는 데 도움을주십시오.
절대 경로 – Gordon
sample.html가 file2.php과 같은 디렉토리에없는 시도? – PoeHaH
file1.php와 file2.php가 모두 같은 디렉토리 – Tarun