How to know what is the current url in php -


so, conditional logic check href url? example, there 3 specific pages.

then write check if current page equal specific url:

 <?php if () { ?> <!--if current page equal `page_1` -->       <span>show page 1</span>  <?php } elseif () { ?> <!--if current page equal `page_2` -->    <span>show page 2</span> <?php } elseif () { ?> <!--if current page equal `page_3` -->    <span>show page 3</span> <?php } else { ?> <!--if current page not equal -->     <span>show random</span> <?php } ?> 

explode url ".com/" check condition.check below code. `enter code here`  1. <?php  $url = "http://example.com/page_1";        $url_ex = explode(".com/",$url);           print_r($url_ex);  2. result = array ( [0] => http://example [1] => page_1 )  <?php if ($url_ex[1] == 'page_1') { ?> <!--if current page equal `page_1` -->       <span>show page 1</span>  <?php } elseif ($url_ex[1] == 'page_2') { ?> <!--if current page equal `page_2` -->    <span>show page 2</span> <?php } elseif ($url_ex[1] == 'page_3') { ?> <!--if current page equal `page_3` -->    <span>show page 3</span> <?php } else { ?> <!--if current page not equal -->     <span>show random</span> <?php } ?> 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -