Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
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
//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
case "switchpages.php":
//Do something unique on switchpages.php
echo "Default action. Page is named something other than what we switched through above.";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment