to test whether the directory /home/david is executable (regardless of whether it is readable or writeable), issue the command:
$my_isWriteable = @file_exists("/home/david/.")
the @ gets rid of the warning when this command fails when the directory is not executable.