Skip to content
Advertisement

Output flickers if I include HTML in PHP

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.

Advertisement

Answer

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. –

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement