gpt4 book ai didi

php - 如果 php 条件满足,将类放入 html

转载 作者:太空宇宙 更新时间:2023-11-04 10:48:48 25 4
gpt4 key购买 nike

我正在使用 html 导航面板,下面是打开选项卡的示例之一。

<li class="nav-item active open">

现在,我希望在我的 url 包含\testing\one 时应用“主动打开”。

我可以使用下面的 php 代码获取该 url,我使用的是 codeigniter。

<?php echo $this->uri->uri_string();?>

我可以将它与 if 语句进行比较,但我的主要问题是如何将此 php if 条件放入

<li></li>

谢谢,

最佳答案

你可以这样做——

<li <?php echo ($this->uri->uri_string() === 'value') ? 'class="nav-item active open"' : '' ?>>

关于php - 如果 php 条件满足,将类放入 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35145530/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com