Every once in a while there is a question involving how to determine the characteristics of a file. I'm reading a book called Pro PHP patterns, frameworks, testing and more. And I just learned about this:
Pretty much lies to rest any discussion on how to determine a file's extension.PHP Code:<?php
$file = '/path/to/file/file.ext';
$pathInfo = pathinfo($file);
echo 'Extension: ' . $pathInfo['extension'] . '</br />';
echo 'Base name: ' . $pathInfo['basename'] . '</br />';
echo 'Directory name: ' . $pathInfo['dirname'] . '</br />';
echo 'File name: ' . $pathInfo['filename'] . '</br />';
?>



Reply With Quote



Bookmarks