Last active
August 29, 2015 14:03
-
-
Save jcefoli/2ed2e0dacf5a85620826 to your computer and use it in GitHub Desktop.
Simple way to get the document name of the page and file extension and uses a switch statement to do something unique based on which page you're on
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
//Gets the document name of the page. For example, index.php | |
$getDocument = explode('/', $_SERVER["PHP_SELF"]); | |
$currentPage = $getDocument[count($getDocument) - 1]; | |
//Switch statement | |
switch ($currentPage) { | |
case "index.php": | |
//do something unique on index.php | |
break; | |
case "switchpages.php": | |
//Do something unique on switchpages.php | |
break; | |
default: | |
echo "Default action. Page is named something other than what we switched through above."; | |
break; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment