排除“解析错误,意外'>'”错误

时间:2011-06-28 14:09:06

标签: php

我收到正在阅读的错误

  

解析错误:解析错误,意外'>'在第11行的C:\ wamp \ www \ about.php

这是我的代码:

<?php
session_start();
include ("include/header.php");
if (!isset($_SESSION['name'])){;
header("Location:includeindex.php");
exit;
 }
 else{
TopNavigation("about Me -ECA236","About Me",$_SESSION['name']);
echo "<p>Here is a little about me. I am a mother of twin girls who are 9 </p>
echo "<p>I been married for 5 years but been with my husband for 11 years </p>
echo "<p>I am attending college for Computer Programming and Database Mangament      </p>
echo "<p>After I get done with this degree I am want to go back for Web Design </p>
echo "<p>since half my classes are web design now. I enjoy camping,bon fires and </p>
echo "<p>playing video games, hanging out with friends and family.</p>
Footer();
   }
 ?>

我尝试过添加;到最后并“到最后但同样的事情突然出现。有人可以看到我做错了什么。

这是我在添加“;到最后:

时得到的错误
  

警告:include(include / header.php)[function.include]:无法打开流:第3行的C:\ wamp \ www \ about.php中没有此类文件或目录

     

警告:include()[function.include]:在C:\ wamp \ www \ about.php中打开'include / header.php'以包含(include_path ='。; C:\ php5 \ pear')失败在第3行

     

警告:无法修改标题信息 - 已在第5行的C:\ wamp \ www \ about.php中发送的标题(在C:\ wamp \ www \ about.php:3处开始输出)

9 个答案:

答案 0 :(得分:5)

你有:

echo "<p>playing video games, hanging out with friends and family.</p>

你需要:

echo "<p>playing video games, hanging out with friends and family.</p>";

答案 1 :(得分:0)

您需要在";

的末尾添加引用echo

答案 2 :(得分:0)

每条回音线的末尾都需要一个引号和一个分号。

一般来说,每当你在PHP中的一行上打开引号时,你还需要关闭它,并且每一行(除了一些例外,例如流程控制语句等)都需要以分号结束。

答案 3 :(得分:0)

您没有关闭引号:

echo“

这里有一点关于我的信息。我是9岁的双胞胎女孩的母亲;

答案 4 :(得分:0)

所有的回声线都需要关闭他们的语音标记并以分号结束。

答案 5 :(得分:0)

您根本没有关闭任何echo语句。以下应该有效:

<?php
session_start();
include ("include/header.php");
if (!isset($_SESSION['name'])){
header("Location:includeindex.php");
exit;
 }
 else{
TopNavigation("about Me -ECA236","About Me",$_SESSION['name']);
echo "<p>Here is a little about me. I am a mother of twin girls who are 9 </p>";
echo "<p>I been married for 5 years but been with my husband for 11 years </p>";
echo "<p>I am attending college for Computer Programming and Database Mangament      </p>";
echo "<p>After I get done with this degree I am want to go back for Web Design </p>";
echo "<p>since half my classes are web design now. I enjoy camping,bon fires and </p>";
echo "<p>playing video games, hanging out with friends and family.</p>";
Footer();
   }
 ?>

我还看到第4行的分号,我觉得不需要 - 删除它。

答案 6 :(得分:0)

试试这个:

session_start();
include_once ("include/header.php");
if (!isset($_SESSION['name'])) {
    header("Location:includeindex.php");
    exit;
}
else {
    TopNavigation("about Me -ECA236", "About Me", $_SESSION['name']);
    echo "<p>Here is a little about me. I am a mother of twin girls who are 9</p>";
    echo "<p>I been married for 5 years but been with my husband for 11 years</p>";
    echo "<p>I am attending college for Computer Programming and Database Mangament</p>";
    echo "<p>After I get done with this degree I am want to go back for Web Design</p>";
    echo "<p>since half my classes are web design now. I enjoy camping,bon fires and</p>";
    echo "<p>playing video games, hanging out with friends and family.</p>";
    Footer();
}

答案 7 :(得分:0)

您的文件的语法错误。下面的示例应该修复它,但是,消息只是意味着输出的一部分确实是代码,因为您错过了正确使用字符串周围的"引号。请记住,字符串也适用于多行,因此这可能更容易理解:

<?php
session_start();
include ("include/header.php");
if (!isset($_SESSION['name']))
{
  header("Location:includeindex.php");
  exit;
} else {
  TopNavigation("about Me -ECA236","About Me",$_SESSION['name']);
  echo "
    <p>Here is a little about me. I am a mother of twin girls who are 9 </p>
    <p>I been married for 5 years but been with my husband for 11 years </p>
    <p>I am attending college for Computer Programming and Database Mangament      </p>
    <p>After I get done with this degree I am want to go back for Web Design </p>
    <p>since half my classes are web design now. I enjoy camping,bon fires and </p>
    <p>playing video games, hanging out with friends and family.</p>
    " # string ends here
    ;
  Footer();
}
?>

甚至更好,因为这是PHP:

<?php
session_start();
include ("include/header.php");
if (!isset($_SESSION['name']))
{
  header("Location:includeindex.php");
  exit;
} else {
  TopNavigation("about Me -ECA236","About Me",$_SESSION['name']);
  ?>
    <p>Here is a little about me. I am a mother of twin girls who are 9 </p>
    <p>I been married for 5 years but been with my husband for 11 years </p>
    <p>I am attending college for Computer Programming and Database Mangament</p>
    <p>After I get done with this degree I am want to go back for Web Design </p>
    <p>since half my classes are web design now. I enjoy camping,bon fires and </p>
    <p>playing video games, hanging out with friends and family.</p>
  <?php
  Footer();
}
?>

答案 8 :(得分:0)

像其他人一样,你需要引号和半冒号。但是,这也忽略了执行此操作的冗长(并且开销较少)方法。例如,您可以在一个echo语句下完成所有操作:

echo"
  <p>>Here is a little about me. I am a mother of twin girls who are 9</p>
  <p>I been married for 5 years but been with my husband for 11 years</p>
  <p>I am attending college for Computer Programming and Database Mangament</p>
";

或者,另一种方法是

$content = " <<<END
  <p>Here is a little about me. I am a mother of twin girls who are 9</p>
  <p>I been married for 5 years but been with my husband for 11 years</p>
  <p>I am attending college for Computer Programming and Database Mangament</p>
END;

echo $content;

最好的解决方案,如果你要做大量的非PHP,只需关闭PHP标签并使用直接HTML进行,你根本不需要担心引号和分号!

?>
  <p>Here is a little about me. I am a mother of twin girls who are 9</p>
  <p>I been married for 5 years but been with my husband for 11 years</p>
  <p>I am attending college for Computer Programming and Database Mangament</p>
<?php

我的观点是,我看到很多<?php></php>重复以及大量echo重复的例子。它有用吗?当然。但这是不必要的。它减慢了你的速度,并创造了更多的机会搞砸了。而且,它只是丑陋!我不想调试它!