Goal: To have my banner only display on the main page, otherwise display another image. I'll achieve this through different CSS ID's, but am wondering what the proper PHP would be to check the page and apply the ID? I can't seem to find this on Google. Thank you for your help
do something like this : <?php $page = $_SERVER['PHP_SELF']; if($page == "./products.php") { print "<div for this or img src"; }elseif($page == "./contact.php"){ print "<div for contact"; } ?> etc.
I've never noticed $_SERVER['PHP_SELF'] returning the script name with a period at the start. This would work just as well if not better: <?php if (substr(strtolower($_SERVER['PHP_SELF']),'products.php')>0) { echo 'display banner for products page'; } else { echo 'display other banners'; } ?> PHP:
So <div id=" <?php if (substr(strtolower($_SERVER['PHP_SELF']),'/store/cart.php?m=content&page=16')>0) { echo 'homepagebanner'; } else { echo 'otherbanner'; } ?> "> Would work? Thanks
How can I make this script specifically check to see if the current page is http://www.domain.com/store/cart.php?m=content&page=1 , if it's not then it gives the otherbanner class? It needs to be 1 specific domain, that's what I am trying to say
<?php $url = 'http://www.domain.com/store/cart.php?m=content&page=1'; $strip_www = true; /* All lowercase upto the end of the hostname, then natural casing */ define( 'CURRENT_URI', strtolower('http' . ((isset($_SERVER['HTTPS']) and $_SERVER['HTTPS']) ? 's' : '') . '://' . (($strip_www) ? str_replace('www.', '', strtolower($_SERVER['HTTP_HOST'])) : $_SERVER['HTTP_HOST'])) . ((isset($_SERVER['SERVER_PORT']) and $_SERVER['SERVER_PORT'] != 80) ? $_SERVER['SERVER_PORT'] : '') . $_SERVER['SCRIPT_NAME'] . ((isset($_SERVER['QUERY_STRING']) and strlen($_SERVER['QUERY_STRING']) > 0) ? '?' . $_SERVER['QUERY_STRING'] : '') ); if ( $url == CURRENT_URI ) echo 'It\'s the URL you entered!'; else echo 'It\'s not.'; PHP: