Find recently changed files

How to search for recently changed files, ie. in last 24 hours Files changed in last 24 hours: find . -mtime -1 -print To find all files modified in the last 24 hours (last full day) in a particular specific directory and its sub-directories: find /directory_path -mtime -1 -print To find all files with regular…

How to get file extension (without parsing file name)

Get file extension without use of explode function of preg functions You can use pathinfo function – it will return an array with elements like: dirname basename extension filename Reading those values you will get proper values. <?php $path_parts = pathinfo(‘/var/www/htdocs/index.php’); echo $path_parts[‘dirname’]; echo $path_parts[‘basename’]; echo $path_parts[‘filename’]; // since PHP 5.2.0 echo $path_parts[‘extension’]; ?>

How to check if function exists?

Or – how to avoid re-declaring functions? Function redeclaration often occurs if you work with different versions of PHP, ie. on development and on production server. In that case we usually use PHP function function_exists. In next example we will check if function money_format is defined or not. if (!function_exists(‘money_format’)) {   function money_format() {…