I'm using the following code to display ads on certain pages, but can't seem to figure out the proper way of adding more than one page. <?php $page=basename($_SERVER['PHP_SELF']); ?> <?php if ( $page == 'index.php' ) : ?> <!-- Adsense code here... --> <?php endif; ?> Code (markup): I tried the following, but had no success. <?php $page=basename($_SERVER['PHP_SELF']); ?> <?php if ( $page == 'index.php' , 'myfiles.php' , 'browse.php' ) : ?> <!-- Adsense code here... --> <?php endif; ?> Code (markup): What would be the proper syntax to display Adsense on those pages? Thanks in advance.
easy btw thats weird lucking php code u have u need logical OR || happy to help, dont forget to spread some reputation i need it <?php $page=basename($_SERVER['PHP_SELF']); if ( ($page == 'index.php') || ($page == 'myfiles.php' ) || ( $page == 'browse.php' ) ){ print '<!-- Adsense code here... -->'; } ?> PHP:
I'm not getting any errors, but the ads are now on every page. The reason for this code is to prevent Adsense from appearing on the registration page (which goes against their TOS). I'm using Uploader v6.1 if that makes any difference.
sorry theres a bug in my code (its early morning here ) here try this <?php $page=basename($_SERVER['PHP_SELF']); if ( ($page == 'index.php') || ($page == 'myfiles.php' ) || ( $page == 'browse.php' ) ){ print '<!-- Adsense code here... -->'; } ?> PHP:
A minor variation that I use because the page list can get lengthy <?php $page=basename($_SERVER['PHP_SELF']); $noAds = array('register.php','signup.php'); //etc if ( !in_array( $page, $noAds) ){ print '<!-- Adsense code here... -->'; } ?> PHP:
I'm a bit clueless when it comes to PHP. Would you be able to use this in HTML code as well (perhaps using a PHP include) or how would one go about using the code. Any help appreciated.