html - How to open a local file/url and include its output into another page via PHP

Hello I have a one page website (the entire site is in one page):
/index.html
I want to wrap the header and footer of that page around another page inside a folder on the server:
/folder/newpage.php
(with headers and footer of /index.html, but different content)
I've isolated the header and footer and saved them in separate files in the root:
/index_header.html
/index_footer.html
If launched from the root they display correctly but I can't seem to include them in the "newpage.php" because none of the CSS, JS and images inside the header and footer are loaded.
I've tried the following 4 methods:
include($_SERVER["DOCUMENT_ROOT"].'/index_header.html');
file_get_contents($_SERVER["DOCUMENT_ROOT"].'/index_header.html');
ob_start();
include($_SERVER["DOCUMENT_ROOT"].'/index_header.html');
$output = ob_get_clean();
echo $output;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://".$_SERVER['HTTP_HOST']."/index_header.html");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
echo $output;
curl_close($ch);
But none of these methods work... Can anyone help me out? Thank you
Answer
Solution:
I've ended up changing all the JS, image and CSS calls to absolute urls starting from the root which allowed me to use include() Thank you
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: you must enable the openssl extension in your php.ini to load information from https://repo.packagist.org
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.