👾 php

php url 체크해서 일치하면 온클래스

(。θᗨθ。) 2022. 4. 26. 10:15
<?php
  function urlChk($lnb){
    $self = $_SERVER["REQUEST_URI"];
    if(strpos($self, $lnb) == true) {echo 'class="on"';}
  }
?>
<div class="snb">
  <ul>
    <li <?php urlChk('event-01') ?>><a href="/ko/event/event-01.php">11111111111</a></li>
    <li <?php urlChk('event_2022_st') ?>><a href="/ko/bbs/board.php?bo_table=event_2022_st">22222</a></li>
    <li <?php urlChk('event-02') ?>><a href="/ko/event/event-02.php">33333333</a></li>
    <li <?php urlChk('event-03') ?>><a href="/ko/event/event-03.php">4444444</a></li>
    <li <?php urlChk('event-04') ?>><a href="/ko/event/event-04.php">55555555</a></li>
    <li <?php urlChk('event-05') ?>><a href="/ko/event/event-05.php">66666666</a></li>
    <li <?php urlChk('event-06') ?>><a href="/ko/event/event-06.php">77777</a></li>
    <li <?php urlChk('event-07') ?>><a href="/ko/event/event-07.php">8888888</a></li>
  </ul>
</div><!-- .snb -->
728x90