dongna2498 2011-08-28 18:36
浏览 22
已采纳

意外=在我发现的PHP剪辑中 - 我该如何解决?

I'm a complete PHP noob, and so I don't know how to troubleshoot this myself. I found this page which I'm trying to implement: http://webdevjunk.com/coding/css/17/php-menu-includes-with-css-style-to-highlight-active-page-link/

I tried to put the snippets into http://www.paulgrantdesign.com/test77/photography/index.php and /test77/photography/includes/nav.php

Why does my index.php say that there's an unexpected "="?

I'd really appreciate the help :)

EDIT: As requested, here's the PHP that's throwing the error

<?php $active[$current] = “class=active”; ?>

<div id="nav">
<ul>
<li <?php echo $active[1] ?>><?php if ($current != 1) { echo “<a href="index.php">Home</a>”; } else { echo “Home”; } ?></li>
<li <?php echo $active[2] ?>><?php if ($current != 2) { echo “<a href="about.php">About</a>”; } else { echo “About”; } ?></li>
<li <?php echo $active[3] ?>><?php if ($current != 3) { echo “<a href="how_it_works.php">How it works</a>”; } else { echo “How it works”; } ?></li>

There's more, but that gives you the idea of where it's going. Each page on the website has the identifier to say which menu item it's identifying. The identifier looks like this:

<?php $current = 3; include ('includes/nav.php'); ?>
  • 写回答

5条回答 默认 最新

  • dtgta48604 2011-08-28 18:47
    关注

    Your first PHP lesson:

    • Do not copy and paste :) Type in
    $active[$current] = "class=active";
    

    instead of copying and pasting it. In fact, I think you will learn more when you type it out.

    By the way, the curly quote “ ” is what caused the error.

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

报告相同问题?

悬赏问题

  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教