PHP 8.5.0 Alpha 1 available for testing

Voting

: eight plus one?
(Example: nine)

The Note You're Voting On

brendy at gmail dot com
19 years ago
On Mac OSX, to see if a file is a FInder alias:

<?PHP
if( getFinderAlias( $someFile , $target ) ) {
echo
$target;
}
else {
echo
"File is not an alias";
}

function
getFinderAlias( $filename , &$target ) {
$getAliasTarget = <<< HEREDOC
-- BEGIN APPLESCRIPT --
set checkFileStr to "
{$filename}"
set checkFile to checkFileStr as POSIX file
try
tell application "Finder"
if original item of file checkFile exists then
set targetFile to (original item of file checkFile) as alias
set posTargetFile to POSIX path of targetFile as text
get posTargetFile
end if
end tell
end try
-- END APPLESCRIPT --
HEREDOC;
$runText = "osascript << EOS\n{$getAliasTarget}\nEOS\n";
$target = trim( shell_exec( $runText ) );
return (
$target == "" ? false : true );
}
?>

<< Back to user notes page

To Top