PHP是可执行的()

这个 是可执行的吗 PHP中的函数是一个内置函数,用于检查指定的文件是否为可执行文件。文件名作为参数发送到 是可执行的吗 函数,如果文件是可执行文件,则返回True,否则返回False。

null

语法:

bool is_executable($file)

使用的参数: 这个 是可执行的吗 PHP中的函数接受一个参数。

  • $file : 它是指定文件的必需参数。

返回值: 如果文件是可执行文件,则返回True,否则返回false。

例外情况

  • 故障时会发出E_警告。
  • 此函数的结果将被缓存,因此clearstatcache()函数用于清除缓存。
  • 对于不存在的文件,is_executable()函数返回false。

下面的程序演示了is_executable()函数。

项目1:

<?php
$myfile = "gfg.exe" ;
// checking whether the file is
// an executable file or not
if ( is_executable ( $myfile ))
echo ( "$myfile: executable!" );
else
echo ( "$myfile: not executable!" );
?>


输出:

gfg.exe is executable!

方案2

<?php
// fileperms() function returns the
// permission as a number on success
// or FALSE on failure
$permissions = fileperms ( "gfg.exe" );
$permvalue = sprintf( "%o" , $permissions );
// checking whether the file is executable
// or not
if ( is_executable ( "gfg.exe" ))
echo ( "Executable file and File "
"Permissions are : $permvalue" );
else
echo ( "Not Executable file and File "
"Permissions are : $permvalue" );
?>


输出:

Executable file and File Permissions are : 0644

参考: http://php.net/manual/en/function.is-executable.php

© 版权声明
THE END
喜欢就支持一下吧
点赞5 分享