我在页面上有这个
<section class="sidebar">
<ul class="sidebar-menu">
<?php require_once 'includes/left.php'; ?>
</ul>
</section>
在此left.php
我有:
<?php
if ($_SESSION['role'] == 1){
echo'
<li class="active">
<a href="index.php">
<i class="fa fa-dashboard"></i> <span>Home</span>
</a>
</li>
<li class="treeview">
<a href="#">
<i class="fa fa-user"></i>
<span>MainMenu</span>
<i class="fa fa-angle-left pull-right"></i>
</a>
<ul class="treeview-menu">
<li><a href=""><i class="fa fa-angle-double-right"></i> Role_1.1</a></li>
<li><a href=""><i class="fa fa-angle-double-right"></i> Role_1.2</a></li>
<li><a href=""><i class="fa fa-angle-double-right"></i> Role_1.3</a></li>
<li><a href=""><i class="fa fa-angle-double-right"></i> Role_1.4</a></li>
<li><a href=""><i class="fa fa-angle-double-right"></i> Role_1.5</a></li>
<li><a href=""><i class="fa fa-angle-double-right"></i> Role_1.6</a></li>
</ul>
</li>
<li class="treeview">
<a href="#">
<i class="fa fa-file"></i>
<span>MainMenu2</span>
<i class="fa fa-angle-left pull-right"></i>
</a>
<ul class="treeview-menu">';
$pdo = Database::connect();
$sql = $pdo->prepare("SELECT form.field_name, form.group_id, form.field_id, cat.form_field_cat_name, cat.group_id
FROM form_fields form JOIN form_fields_category cat
ON form.group_id = cat.group_id
WHERE form.group_id = cat.group_id
GROUP BY form.group_id ");
$sql->execute();
$rows = $sql->fetchAll();
$html = [];
foreach ($rows as $row) {
$html [] = '<li><a href=""><i class="fa fa-angle-double-right"></i> Role_1 "' . $row['form_field_cat_name'] . '"</a></li>';
}
echo join("", $html);
Database::disconnect();
}
elseif ($_SESSION['role'] == 2)
{
echo '
<li class="active">
<a href="index.php">
<i class="fa fa-dashboard"></i> <span>Home</span>
</a>
</li>
<li class="treeview">
<a href="#">
<i class="fa fa-user"></i>
<span>MainMenu</span>
<i class="fa fa-angle-left pull-right"></i>
</a>
<ul class="treeview-menu">
<li><a href=""><i class="fa fa-angle-double-right"></i> Role_1.3</a></li>
<li><a href=""><i class="fa fa-angle-double-right"></i> Role_1.4</a></li>
<li><a href=""><i class="fa fa-angle-double-right"></i> Role_1.5</a></li>
<li><a href=""><i class="fa fa-angle-double-right"></i> Role_1.6</a></li>
</ul>
</li>
<li class="treeview">
<a href="#">
<i class="fa fa-file"></i>
<span>MainMenu2</span>
<i class="fa fa-angle-left pull-right"></i>
</a>
<ul class="treeview-menu">';
$pdo = Database::connect();
$sql = $pdo->prepare("SELECT form.field_name, form.group_id, form.field_id, cat.form_field_cat_name, cat.group_id
FROM form_fields form JOIN form_fields_category cat
ON form.group_id = cat.group_id
WHERE form.group_id = cat.group_id
GROUP BY form.group_id ");
$sql->execute();
$rows = $sql->fetchAll();
$html = [];
foreach ($rows as $row) {
$html [] = '<li><a href=""><i class="fa fa-angle-double-right"></i> Role_2 "' . $row['form_field_cat_name'] . '"</a></li>';
}
echo join("", $html);
Database::disconnect();
}
在这个left.php
我只有2个菜单,根据用户角色,我会显示哪个菜单适合他/她。问题是我的主机在运行页面时向我显示错误500。并且托管错误日志中的问题是
EACCELERATOR: PHP crashed
当我删除此include 'includes/left.php'
页面正常运行时。有人能解释一下导致这个错误的原因吗? left.php
中有什么问题?