269 of 410 menu

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

is_executable(filename);

Example

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

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

Code execution result:

true

Example

Let's check a non-existent file:

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

Code execution result:

false

Example

Let's check a regular text file:

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

Code execution result:

false

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
byenru