Forum Moderators: coopster
Let me provide you the bit of code:
<?php
if($_GET['language']=="fr"){
$language = "fr";
}else{
$language = "en";
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="<?php echo $language;?>" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Here you can see the small manipulation I make in the "lang" attribute of the "html" element.
When I add it as so - my page sometimes shows blank white screen for a part of the second and then loads the page.
You could say it looks like a brief white blink. I guess it doesn't do any damage, but it sure looks anoying. This ONLY happens if I try to manipulate the "html" code by PHP. I tested it with and without at least 100 times.
If I leave it static as this:
<?php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
It always loads without the blank white screen.
What could be causing this?
I'm testing it on localhost, firefox.
Shouldn't a page be pre-compiled by PHP on the server and then simply outputted to the browser?
Is there any unknown rule that I'm not aware of? I thought it would be perfectly fine to make such changes with PHP.
If you had similar situations or have a clue on what could be causing this behavior, please comment :)
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="'.$language.'" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="content-language" content="'.$language.'">
</head>';
When you echo the whole upper html tags, there are no more "hiccups" like before. Still interested to find out why they were happening in the previous code..
But this solution works well.
[w3.org...]