Created
June 21, 2017 20:28
-
-
Save IronGhost63/d8deb0ef9c5014b5c67e6af7bf76bd48 to your computer and use it in GitHub Desktop.
add .active if current url match href
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function show_url($url, $text = ''){ | |
$current = $uri = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; | |
echo '<a href="'.$url.'" '.($current == $url ? 'class="active"' : '').'>'.(empty($text) ? $url : $text).'</a>'; | |
} | |
?> | |
<div><?php show_url('https://jirayu.in.th', 'Website'); ?></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment