Echo if Page Equals


/ Published in: PHP
Save to your folder(s)

Echo content only if you are on a certain page. Change == to != in order to echo on every page except a certain page.


Copy this code and paste it in your HTML
  1. <?php
  2. if ( $_SERVER[SCRIPT_NAME] == '/page2.php' ) {
  3. echo 'Some text!';
  4.  
  5. } else {
  6. echo '';
  7.  
  8. }
  9. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.