繁体   English   中英

将视口标签添加到header.php会导致php错误

[英]Adding viewport tag to header.php causes php error

我正在使用一个包含文件header.php和正常网页标题信息的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

感谢您的帮助!

您没有在此处转义双引号

<?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>";
?>

使用单引号

<?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>";
?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM