I am currently designing a website which uses this: <li class="current">.
I have gotten a script to detect when it’s on said page to output the right class, however, when on the gallery.php?dir=thedir page, it fails to output the class!
Here’s what I have so far, which is not working…
$ispage = preg_match_all('gallery.php/\[(.+?)\]/s');
I would appreciate any information somebody could give me :).
Full code:
<?php
$ispage = preg_match_all('gallery.php/\[(.+?)\]/s');
$currentpage = $_SERVER['REQUEST_URI'];
if ($ispage==$currentpage) {
echo '<li class="current">';
} else {
echo '<li>';
}
?><a href="gallery.php">Photos</a></li>
Can’t you use $_SERVER[‘SCRIPT_NAME’] or $_SERVER[‘PHP_SELF’] or $_SERVER[‘REQUEST_URI’] along with php function strpos($haystack, $findme)? It should make your life easy.
http://php.net/manual/en/function.strpos.php