0

我正在使用一个 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

感谢您对此的任何帮助!

4

1 回答 1

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

使用单引号

<?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>";
?>
于 2013-07-24T03:31:10.103 回答