【发布时间】:2017-11-30 17:27:30
【问题描述】:
我通过“incude”语句在“index.php”上调用我的页面。我不得不使用“isset”来让它们工作,但是当我单击导航栏中的链接时,“yourtweets.php”没有加载。我使用正确吗?
链接代码;
<a href="?page=yourtweets" class="nav-link">Your Tweets</a>
index.php 代码;
<?php
include("functions.php");
include("views/header.php");
if (isset($_GET['page']) == 'timeline') {
include("views/timeline.php");
} else if (isset($_GET['page']) == 'yourtweets') {
include("views/yourtweets.php");
} else {
include("views/home.php");
}
?>
【问题讨论】:
-
isset()返回一个布尔值,而不是字符串。你不能比较 isset() == "a string"。试试if (isset($_GET['page']) && $_GET['page'] == 'yourtweets') -
@EatPeanutButter 如果我将它用于我的所有菜单项,那就行得通了。 ty