将viewport标记添加到header.php会导致php错误

时间:2013-07-24 03:29:13

标签: php viewport

我正在使用一个php脚本,它有一个带有正常网页标题信息的文件header.php。但是,当我添加视口标记时,它会抛出错误。

的header.php:

<?php
/*
UserCake Version: 2.0.2
http://usercake.com
*/
echo "
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>  
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<title>".$websiteName."</title>
<link href='".$template."' rel='stylesheet' type='text/css' />
<script src='models/funcs.js' type='text/javascript'>
</script>
</head>";

?>

返回错误:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /homepages/30/d332080598/htdocs/azotusorg/usercake/models/header.php on line 10

感谢您提供任何帮助!

1 个答案:

答案 0 :(得分:0)

你没有在这里转发双引号

<?php
echo "
 <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
 <html xmlns='http://www.w3.org/1999/xhtml'>
 <head>
 <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/>  
 <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
 <title>".$websiteName."</title>
 <link href='".$template."' rel='stylesheet' type='text/css' />
 <script src='models/funcs.js' type='text/javascript'>
 </script>
 </head>";
?>

OR 使用单引号

<?php
echo "
 <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
 <html xmlns='http://www.w3.org/1999/xhtml'>
 <head>
 <meta name='viewport' content='width=device-width, initial-scale=1.0'/>  
 <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
 <title>".$websiteName."</title>
 <link href='".$template."' rel='stylesheet' type='text/css' />
 <script src='models/funcs.js' type='text/javascript'>
 </script>
 </head>";
?>