li class 主动自动

li class active automatic

class="active" 自动更改帮助我。

<li>
    <a href="home.php">
    <i class="icon-home"></i>
    <span class="title">Home</span>
    <span class="selected"></span>
    <span class="arrow"></span>
    </a>                    
</li>
<li class="active open">
    <a href="general-settings.php">
    <i class="icon-home"></i>
    <span class="title">General Settings</span>
    <span class="selected"></span>
    <span class="arrow"></span>
    </a>                    
</li>

我可以

home.php 第

<li class="active open">

一般 - settings.php 第

<li class="active open">

示例

首页在

<li active="active open">
        <a href="home.php">
        <i class="icon-home"></i>
        <span class="title">Home</span>
        <span class="selected"></span>
        <span class="arrow"></span>
        </a>                    
</li>

试试 php

<?php 
$directoryURI = $_SERVER['REQUEST_URI'];
$path = parse_url($directoryURI, PHP_URL_PATH);
$components = explode('/', $path);
$first_part = $components[1];
?>

html部分

<li class="<?php if ($first_part=="home.php") {echo "active open"; }?>">
    <a href="home.php">
    <i class="icon-home"></i>
    <span class="title">Home</span>
    <span class="selected"></span>
    <span class="arrow"></span>
    </a>                    
</li>
<li class="<?php if ($first_part=="general-settings.php") {echo "active open"; }?>">
    <a href="general-settings.php">
    <i class="icon-home"></i>
    <span class="title">General Settings</span>
    <span class="selected"></span>
    <span class="arrow"></span>
    </a>                    
</li>