note 123883 added to function.is-executable

From: Date: Fri, 24 May 2019 21:41:44 +0000
Subject: note 123883 added to function.is-executable
Groups: php.notes 
Request: Send a blank email to php-notes+get-211115@lists.php.net to get a copy of this message
is_executable() does not check the PATH environment variable, so if your current working dir is /dir/ and you /bin/ in your PATH env and the file /bin/ffmpeg exists, then you can still run shell_exec("ffmpeg"), but is_executable("ffmpeg") will return false. if you're looking for a version of is_executable that also considers the PATH environment variable, then try this: <?php function is_executable_pathenv(string $filename): bool { if (is_executable($filename)) { return true; } if ($filename !== basename($filename)) { return false; } $separator = (stripos(PHP_OS_FAMILY, "win") === false ? ":" : ";"); $paths = explode($separator, getenv("PATH")); foreach ($paths as $path) { if (is_executable($path . DIRECTORY_SEPARATOR . $filename)) { return true; } } return false; } ---- Server IP: 208.43.231.9 Probable Submitter: 185.85.3.195 (proxied: 85.164.164.153) ---- Manual Page -- http://php.net/manual/en/function.is-executable.php Edit -- https://master.php.net/note/edit/123883 Del: integrated -- https://master.php.net/note/delete/123883/integrated Del: useless -- https://master.php.net/note/delete/123883/useless Del: bad code -- https://master.php.net/note/delete/123883/bad+code Del: spam -- https://master.php.net/note/delete/123883/spam Del: non-english -- https://master.php.net/note/delete/123883/non-english Del: in docs -- https://master.php.net/note/delete/123883/in+docs Del: other reasons-- https://master.php.net/note/delete/123883 Reject -- https://master.php.net/note/reject/123883 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#211115) next »