-3
if (isset($_GET["nav"])) {
    if (!empty($_GET)) {
        $linkn = $_GET['nav'];
        if ($linkn == "nav1") {
            include("nav1.php");
        }
        if ($linkn == "nav2") {
            include("nav2.php");
        }
    } 
    else {
        include("nav1.php");
    }
}

我似乎无法了解 nav2.php 任何想法?

对不起,我在建造它时很着急。这里发生的事情是在我的 index.php 右导航中,我已经为我的导航分离了 php,即 nav1、nav2。但我似乎无法通过导航进行更改,我有这段代码,我知道缺少一些东西。

4

1 回答 1

1
$include = $_GET;
//Allowed navigations
$allowed = array('nav1', 'nav2');

//var must exist, have value and exist in allowed array
if (isset($_GET["nav"]) && !empty($_GET) && in_array($include, $allowed)){ 
  include($include.'.php');      
} else {
  include('nav1.php');
}
于 2013-01-08T04:10:48.230 回答