dtkz3186 2013-09-10 13:21
浏览 18
已采纳

PHP语法错误

I posted this question a little earlier but here is the full version. I keep getting a Syntax Error which is solved when I remove the following code. So there must be a problem here, I just can't see what it is.

The syntax error is: "The topic (none) was not found in any of the reference materials currently installed".

 <?php

$ds = 'Pear';
$sd = 'Orange';
$dt = 'Banana';
$td = 'KiwiFruit';


$FoodArray=array();

echo "<p>";

foreach ($_POST ["Gender"] as $value) {
    if ($value == Female) {
    $FoodArray=array($ds, $sd, $dt, $td);
    echo "<ul>";
foreach ($FoodArray as $key => $value)

{
    echo "<li>" . $value . "</li>";
}
    echo "</ul>";
}



?>

This is the only thing stopping me from finishing a project, so I would be grateful to anyone who can help. I will try to answer a few of your questions too.

  • 写回答

5条回答 默认 最新

  • douyuan4697 2013-09-10 13:26
    关注

    The following code:

    if($value == Female)
    

    would produce a notice, not an error. However, I know from experience that someone inheriting code that relies on PHP bare strings being interpreted as strings will hate the person who wrote it for the rest of their life.

    PHP Notice: Use of undefined constant Female - assumed 'female' in file on line #

    Your error is you're missing a curly brace at the end. Not sure if it's just the code you posted here or if that is indeed the format of your code, but using correct indentation practices will help you avoid these types of issues, as well as help others spot check your code for you.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 请问为什么我配置IPsec后PC1 ping不通 PC2,抓包出来数据包也并没有被加密
  • ¥200 求博主教我搞定neo4j简易问答系统,有偿
  • ¥15 nginx的使用与作用
  • ¥100 关于#VijeoCitect#的问题,如何解决?(标签-ar|关键词-数据类型)
  • ¥15 一个矿井排水监控系统的plc梯形图,求各程序段都是什么意思
  • ¥50 安卓10如何在没有root权限的情况下设置开机自动启动指定app?
  • ¥15 ats2837 spi2从机的代码
  • ¥200 wsl2 vllm qwen1.5部署问题
  • ¥100 有偿求数字经济对经贸的影响机制的一个数学模型,弄不出来已经快要碎掉了
  • ¥15 数学建模数学建模需要