dounieliang4712 2012-05-27 22:42
浏览 48

如何重置GET变量

Please pardon my PHP noobness! I want a single page to display a particular navigation based on the incoming link. It's set up as follows:

page1.php list item:

<li><a <?php if (strpos($_SERVER['PHP_SELF'], 'wood-species.php')) echo 'class="current"';?>href="wood-species.php?name=standard">Wood Species</a></li>

page2.php list item:

<li><a <?php if (strpos($_SERVER['PHP_SELF'], 'wood-species.php')) echo 'class="current"';?>href="wood-species.php?name=premium">Wood Species</a></li>

So the first link will set the name variable to "standard" using the GET method, and the second link will set it to "premium". So what I want to happen is that 'wood-species.php' displays with the appropriate navigation, but I'm not sure how to destroy or unset the 'name' variable.

Here's what I tried to use, obviously not getting it done...

 <?php

    $woodclass = $_GET['name'];
    if($woodclass="premium") {
    require("includes/premium-wide-navigation.php"); 
    echo"premium";
    clearit();
    }

    else if($woodclass="standard") {
    require("includes/standard-wide-navigation.php");
    echo"standard";
    clearit();
    }
    else {
    //
    }

    function clearit () {
    unset($GLOBALS['woodclass']);
    }

?>
  • 写回答

3条回答 默认 最新

  • dpowhyh70416 2012-05-27 22:45
    关注

    I think that unset($_GET['name']); should do the job.

    评论

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答