Check your body id with PHP

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

Previously, I posted a little snippet I found on how to generate a special body class on each .php page. I, later, needed to get that body class and echo out a piece of HTML, which depended on my current page. So here is the snippet that I came up with. Simple, but was useful for me.

Copy this code and paste it in your HTML
  1. <?php
  2. $id = basename($_SERVER['PHP_SELF'], ".php");
  3. $register_btn = "<a class='btnRegister'>THIS CAN BE WHATEVER YOU WANT TO ECHO OUT.</a>";
  5. if ($id != "workshops"){
  6. echo $register_btn;
  7. }
  8. ?>

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.