This snippet gets the current file name for later use.
Code:
<?php
$currentFile = $_SERVER["PHP_SELF"]; //get the full file path
$parts = Explode('/', $currentFile); //split the path in to an array on /
$filename = $parts[count($parts) - 1]; //get the last element of the parts array which is the just the file name
?>
Example:
Echo out the stored file name and path.
<?php echo $currentFile; //prints the full path to the file echo "<br/>"; echo $filename; //prints just the file name with extension ?>
Results:
/Code-Snippets/ADD/getFileName.php getFileName.php
