src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php
public static function findExecutableInPath( $fileName )
    {
        if ( array_key_exists( 'PATH', $_ENV ) )
        {
            $envPath = trim( $_ENV['PATH'] );
        }
        else if ( ( $envPath = getenv( 'PATH' ) ) !== false )
        {
            $envPath = trim( $envPath );
        }
        if ( is_string( $envPath ) && strlen( trim( $envPath ) ) == 0 )
        {
            $envPath = false;
        }

        switch ( self::os() )
        {
            case 'Unix':
            case 'FreeBSD':
            case 'Mac':
            case 'MacOS':
            case 'Darwin':
            case 'Linux':
            case 'SunOS':
                if ( $envPath )
                {
                    $dirs = explode( ':', $envPath );
                    foreach ( $dirs as $dir )
                    {
                        // The @-operator is used here mainly to avoid
                        // open_basedir warnings. If open_basedir (or any other
                        // circumstance) prevents the desired file from being
                        // accessed, it is fine for file_exists() to return
                        // false, since it is useless for use then, anyway.
                        if ( file_exists( "{$dir}/{$fileName}" ) )
                        {
                            return "{$dir}/{$fileName}";
                        }
                    }
                }
                // The @-operator is used here mainly to avoid open_basedir
                // warnings. If open_basedir (or any other circumstance)
                // prevents the desired file from being accessed, it is fine
                // for file_exists() to return false, since it is useless for
                // use then, anyway.
                elseif ( @file_exists( "./{$fileName}" ) )
                {
                    return $fileName;
                }
                break;
            case 'Windows':
                if ( $envPath )
                {
                    $dirs = explode( ';', $envPath );
                    foreach ( $dirs as $dir )
                    {
                        // The @-operator is used here mainly to avoid
                        // open_basedir warnings. If open_basedir (or any other
                        // circumstance) prevents the desired file from being
                        // accessed, it is fine for file_exists() to return
                        // false, since it is useless for use then, anyway.
                        if ( @file_exists( "{$dir}\\{$fileName}.exe" ) )
                        {
                            return "{$dir}\\{$fileName}.exe";
                        }
                    }
                }
                // The @-operator is used here mainly to avoid open_basedir
                // warnings. If open_basedir (or any other circumstance)
                // prevents the desired file from being accessed, it is fine
                // for file_exists() to return false, since it is useless for
                // use then, anyway.
                elseif ( @file_exists( "{$fileName}.exe" ) )
                {
                    return "{$fileName}.exe";
                }
                break;
        }
        return null;
    }
public static function findExecutableInPath( $fileName )
    {
        if ( array_key_exists( 'PATH', $_ENV ) )
        {
            $envPath = trim( $_ENV['PATH'] );
        }
        else if ( ( $envPath = getenv( 'PATH' ) ) !== false )
        {
            $envPath = trim( $envPath );
        }
        if ( is_string( $envPath ) && strlen( trim( $envPath ) ) == 0 )
        {
            $envPath = false;
        }

        switch ( self::os() )
        {
            case 'Unix':
            case 'FreeBSD':
            case 'Mac':
            case 'MacOS':
            case 'Darwin':
            case 'Linux':
            case 'SunOS':
                if ( $envPath )
                {
                    $dirs = explode( ':', $envPath );
                    foreach ( $dirs as $dir )
                    {
                        // The @-operator is used here mainly to avoid
                        // open_basedir warnings. If open_basedir (or any other
                        // circumstance) prevents the desired file from being
                        // accessed, it is fine for file_exists() to return
                        // false, since it is useless for use then, anyway.
                        if ( file_exists( "{$dir}/{$fileName}" ) )
                        {
                            return "{$dir}/{$fileName}";
                        }
                    }
                }
                // The @-operator is used here mainly to avoid open_basedir
                // warnings. If open_basedir (or any other circumstance)
                // prevents the desired file from being accessed, it is fine
                // for file_exists() to return false, since it is useless for
                // use then, anyway.
                elseif ( @file_exists( "./{$fileName}" ) )
                {
                    return $fileName;
                }
                break;
            case 'Windows':
                if ( $envPath )
                {
                    $dirs = explode( ';', $envPath );
                    foreach ( $dirs as $dir )
                    {
                        // The @-operator is used here mainly to avoid
                        // open_basedir warnings. If open_basedir (or any other
                        // circumstance) prevents the desired file from being
                        // accessed, it is fine for file_exists() to return
                        // false, since it is useless for use then, anyway.
                        if ( @file_exists( "{$dir}\\{$fileName}.exe" ) )
                        {
                            return "{$dir}\\{$fileName}.exe";
                        }
                    }
                }
                // The @-operator is used here mainly to avoid open_basedir
                // warnings. If open_basedir (or any other circumstance)
                // prevents the desired file from being accessed, it is fine
                // for file_exists() to return false, since it is useless for
                // use then, anyway.
                elseif ( @file_exists( "{$fileName}.exe" ) )
                {
                    return "{$fileName}.exe";
                }
                break;
        }
        return null;
    }
public static function findExecutableInPath ( $ fileName ) { if ( array_key_exists ( 'PATH' , $ _ENV ) ) { $ envPath = trim ( $ _ENV [ 'PATH' ] ) ; } else if ( ( $ envPath = getenv ( 'PATH' ) ) !== false ) { $ envPath = trim ( $ envPath ) ; } if ( is_string ( $ envPath ) && strlen ( trim ( $ envPath ) ) == 0 ) { $ envPath = false ; } switch ( self :: os ( ) ) { case 'Unix' : case 'FreeBSD' : case 'Mac' : case 'MacOS' : case 'Darwin' : case 'Linux' : case 'SunOS' : if ( $ envPath ) { $ dirs = explode ( ':' , $ envPath ) ; foreach ( $ dirs as $ dir ) { // The @-operator is used here mainly to avoid // open_basedir warnings. If open_basedir (or any other // circumstance) prevents the desired file from being // accessed, it is fine for file_exists() to return // false, since it is useless for use then, anyway. if ( file_exists ( "{$dir}/{$fileName}" ) ) { return "{$dir}/{$fileName}" ; } } } // The @-operator is used here mainly to avoid open_basedir // warnings. If open_basedir (or any other circumstance) // prevents the desired file from being accessed, it is fine // for file_exists() to return false, since it is useless for // use then, anyway. elseif ( @ file_exists ( "./{$fileName}" ) ) { return $ fileName ; } break ; case 'Windows' : if ( $ envPath ) { $ dirs = explode ( ';' , $ envPath ) ; foreach ( $ dirs as $ dir ) { // The @-operator is used here mainly to avoid // open_basedir warnings. If open_basedir (or any other // circumstance) prevents the desired file from being // accessed, it is fine for file_exists() to return // false, since it is useless for use then, anyway. if ( @ file_exists ( "{$dir}\\{$fileName}.exe" ) ) { return "{$dir}\\{$fileName}.exe" ; } } } // The @-operator is used here mainly to avoid open_basedir // warnings. If open_basedir (or any other circumstance) // prevents the desired file from being accessed, it is fine // for file_exists() to return false, since it is useless for // use then, anyway. elseif ( @ file_exists ( "{$fileName}.exe" ) ) { return "{$fileName}.exe" ; } break ; } return null ; }
Returns the path of the specified executable, if it can be found in the system's path.

It scans the PATH enviroment variable based on the OS to find the
$fileName. For Windows, the path is with \, not /.  If $fileName is not
found, it returns null.

@todo consider using getenv( 'PATH' ) instead of $_ENV['PATH']
(but that won't work under IIS)

@param string $fileName
@return string
Returns the path of the specified executable if it can be found in the system s path .