Syntax adjustments #488
This commit is contained in:
parent
61d927b2b7
commit
aba1629f31
@ -1,18 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
# Returns the extension of the filename (path or URI) or an empty string
|
/**
|
||||||
|
* Returns the extension of the filename (path or URI) or an empty string.
|
||||||
|
* @return string Extension of the filename starting with a dot.
|
||||||
|
*/
|
||||||
function getExtension($filename, $isURI = false) {
|
function getExtension($filename, $isURI = false) {
|
||||||
|
|
||||||
# If $filename is an URI, get only the path component
|
// If $filename is an URI, get only the path component
|
||||||
if ($isURI)
|
if ($isURI===true) $filename = parse_url($filename, PHP_URL_PATH);
|
||||||
$filename = parse_url($filename, PHP_URL_PATH);
|
|
||||||
|
|
||||||
$extension = pathinfo($filename, PATHINFO_EXTENSION);
|
$extension = pathinfo($filename, PATHINFO_EXTENSION);
|
||||||
|
|
||||||
if (!empty($extension))
|
if (empty($extension)===false) $extension = '.' . $extension;
|
||||||
$extension = '.' . $extension;
|
|
||||||
|
|
||||||
return $extension;
|
return $extension;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue
Block a user