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条)

报告相同问题?

悬赏问题

  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services