The is_executable Function

The is_executable function checks if the specified file can be executed. It returns true if the file exists and is executable, and false otherwise. It accepts a file path as a string parameter.

Syntax

phpis_executable(filename);

Example

Let's check if the file 'script.php' is executable:

php<?php
  $res = is_executable('script.php');
  var_dump($res);
?>

Code execution result:

phptrue

Example

Let's check a non-existent file:

php<?php
  $res = is_executable('nonexistent.php');
  var_dump($res);
?>

Code execution result:

phpfalse

Example

Let's check a regular text file:

php<?php
  $res = is_executable('readme.txt');
  var_dump($res);
?>

Code execution result:

phpfalse

See Also

  • the is_readable function,
    which checks readability
  • the is_writable function,
    which checks writability
  • the chmod function,
    which changes access permissions
  • the is_file function,
    which checks if it's a file