Tag Archives: filename
How to remove an extension from a filename
If you need for any reason to remove an extension from a filename (string) this snippet can help you. An extension in this case is everything after the last period from the whole string.
Read moreGet filename extension
This snippet can help you to get the extension of a filename:
<?php
… some code here …
// Filename
$filename = ‘public_html/root/internet.gif’;
// Extension
$ext = strrchr($filename, “.”);
echo $ext; // will return “.gif”
?>
Get filename of the currently executing script
Using this piece of code you will get the filename of the currently executing script without containing the full path to it.
For instance if $_SERVER['PHP_SELF'] is equal with /public_html/web/login.php our code will return only login.php
$self = basename($_SERVER['PHP_SELF']);
Read more