Output flickers if I include HTML in PHP
Get the solution ↓↓↓for my website i have some static header/footer HTML and some dynamic content generated by PHP. When it comes to render the output I just include a file with HTML inside from my PHP code. This works perfect - also when I switch between pages.
<?php
...
public function render() {
...
// file for output
include $fileName;
...
}
?>
But I also need some header.hmtl and footer.html that contains the static information (text and some divs for formating) and want to put that in front of each dynamic content, represented by $fileName.
So I simply add two includes that represent the static information.
// file for output
include "./Views/html/header.html";
include $fileName;
include "./Views/html/footer.html";
So this does what I like (formatting, etc.), but if I switch from page to page it flickers for one time. As much as I can see the page is first renderd without header/footer information and then a second time with header/footer information. Looks like this generates the flickering.
How can I avoid this ? Is this probable related to a RewriteRule of my MVC-Framework ?
Any hint is appreciated.
Answer
Solution:
thanks to Lawrence who led me to the right term. It solved my problem completely.
I put a<body><script>0</script><!-- rest of the code --></body>
in my code and it works now. –
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: invalid argument supplied for foreach() laravel
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.