Using PHP, is there a way to test if the browser is accessing a certain page?
For example, I have a header file called header.php which is being pulled into a couple different pages. What I want to do is when I go to a different page, I want to append certain variable to the title.
Example.
Inside header.php:
<?php
$titleA = " Online Instruction";
$title B = "Offline";
?>
<h2>Copyright Info: <?php if ('onlineinstruction'.php) echo $titleA; ?> </h2>
edit: also if you believe there is a simpler way to do this, let me know!
You can use
$_SERVER['REQUEST_URI'],$_SERVER['PHP_SELF'], or__FILE__depending on your version of PHP and how you have your code setup. If you are in a framework it may have a much more developer-friendly function available. For example, CodeIgniter has a function calledcurrent_url()Per PHP Docs: