How do you get JUST the current files name that is being used? I need the name only (myFile.php NEEDS TO BE myFile)
$_SERVER
and __FILE__
constants are NOT the answers I am looking for.
How do you get JUST the current files name that is being used? I need the name only (myFile.php NEEDS TO BE myFile)
$_SERVER
and __FILE__
constants are NOT the answers I am looking for.
basename(__FILE__, '.php');
See also here: http://php.net/basename, or, if you like
pathinfo(__FILE__, PATHINFO_FILENAME);
This last one works also if the extension is different from .php without the need to specify it, see http://php.net/manual/en/function.pathinfo.php
Try strstr :
<?php
$file = 'myFile.php';
$name = strstr($file, '.');
echo $name; // prints .php
$file = 'myFile.php';
$name = strstr($file, '.' ,true);
echo $name; // prints myFile
?>
You can find more examples on how to use this at http://us1.php.net/manual/en/function.strstr.php
This should work for you.