我有一個sidebar-right.html
文件,它具有以下元素的側欄。如何使用php包含文件將活動類添加到元素
<div class="col-sm-2">
<div class="list-group">
<a href="Sub-Investment.php" class="list-group-item">New investment plan</a>
<a href="open-creditcard.php?action=credit" class="list-group-item">Apply credit card</a>
<a href="open-creditcard.php?action=limit" class="list-group-item">Increase credit limit</a>
</div>
</div>
</div>
</div>
</div>
我叫這個頁面在另一個文件名爲open-creditcard.php
使用include "..\View\\sidebar-right.html";
所以我對這個網頁的最終網址將是這樣的:http://localhost/obis/Controller/open-creditcard.php?action=limit
或http://localhost/obis/Controller/open-creditcard.php?action=credit
我想補充一類active
動態使用php,在sidebar-right.html
中的列表組。
我想是這樣的:
<a href="open-creditcard.php?action=credit" class="list-group-item" <?php if($_SERVER['PHP_SELF'] == "/open-creditcard.php?action=credit") echo 'class="list-group-item active"'; ?>>Apply credit card</a>
但它不工作。有什麼我想念?有誰能夠幫助我?
非常感謝。它運作良好! – user1012181
我們如何動態更改頁面的標題? – user1012181