PHP Tutorial - PHP is_executable() Function






Definition

The is_executable() function checks whether the specified file is executable.

Syntax

PHP is_executable() Function has the following syntax.

is_executable(file)

Parameter

ParameterIs RequiredDescription
fileRequired.File to check

Return

This function returns TRUE if the file is executable.

Note

The result of this function are cached. Use clearstatcache() to clear the cache.





Example

is_executable() returns true if the string parameter is executable.

For example, to check whether a file is executable:


<?PHP/*from   ww  w.  j a va 2s. c  o m*/
      $filename = 'c:\boot.ini'; // Windows
      $filename = '/etc/passwd'; // Unix

      if (is_executable($filename)) {
             print 'File executable!';
      } else {
             print 'File not executable!';
      }
      
?>

The code above generates the following result.