public function genMenu($parent_id, $menu_type, $utype, $parent_token=0, $currentpage = 0) {
$stmt = $this->db->prepare("SELECT n.page_id, p.short_name, p.token FROM navigation AS n, pages AS p, user_page_restr AS r WHERE n.parent_id = ? AND r.pg_id=p.id AND n.menu=? AND (r.user_type=? OR r.user_type=0) AND n.page_id=p.id ORDER BY r.order") or die($this->db->error);
$stmt->bind_param("iii", $parent_id, $menu_type, $utype) or die($stmt->error);
$stmt->execute() or die($stmt->error);
$stmt->store_result();
$menu = array();
$stmt->bind_result($menu['id'], $menu['short_name'], $menu['token']) or die($stmt->error);
if ($stmt->num_rows > 0)
echo "\n<ul>\n";
while ($stmt->fetch()) {
echo "<li ";
if ($menu['token']==$currentpage) {
echo 'class="active"';
}
echo ">";
switch ($menu_type) {
case 2:
echo '<a href="?page=' . $parent_token;
echo '&subpage=' . $menu['token'];
echo '">' . $menu['short_name'] . '</a>';
break;
default:
echo '<a href="?page=' . $menu['token'] . '">' . $menu['short_name'] . '</a>';
break;
}
echo "</li>\n\n";
}
if ($stmt->num_rows > 0)
echo "</ul>\n";
$stmt->close();
}
![enter image description here](https://i.stack.imgur.com/2bPLb.png)
Посмотрите на это
if ($menu['token']==$currentpage) {
echo 'class="active"';
}
Даже если $ menu ['token'] является строкой и имеет точное значение, а $currentpage
равно 0, если условие возвращает результат true и выполняет выражение внутри if (echo 'class="active"';
)
Может кто-нибудь объяснить, почему это происходит?