HTML呈现问题 - 适用于Mozilla Firefox,但不适用于Google Chrome

时间:2016-07-21 11:16:36

标签: php html google-chrome firefox

以下Php文件使用Mozilla Firefox完美呈现。但是,在Google Chrome上运行相同内容时;结果 - 它显示整个HTML代码而不是呈现它。基本上表示Google Chrome浏览器无法理解并显示HTML代码。

  

abc.php文件

  <?php  
session_start();//session is a way to store information (in variables) to be used across multiple pages.  
?>
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.12.3.js"></script>        
.... //some lines of code
</html>

1 个答案:

答案 0 :(得分:1)

问题是

Firefox浏览器解析并呈现HTML代码。 谷歌浏览器无法理解php文件本身就是HTML代码。

解决方案

  

将DOCTYPE行放置为文件的第一行

因此,更改是DOCTYPE行的定位,指示要在浏览器上显示的文档类型。

  

abc.php文件

<!DOCTYPE html>
<?php  
session_start();//session is a way to store information (in variables) to be used across multiple pages.  
?>

<html>
<head>
<script src="https://code.jquery.com/jquery-1.12.3.js"></script>        
.... //some lines of code
</html>