Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

php fopen returns false but file is readable/writable

have a file that is readable and writable but fopen is returning false...

if(is_readable($file)) echo 'readable ';
if(is_writable($file)) echo 'writable ';
$fp = fopen($file, 'a+');
var_dump($fp);

result is

readable writable bool(false)

Any ideas?

sure it must be a permission thing but tried 777 on the file with same results.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Let's try to get more information.
What does

$file = 'p:muh';

error_reporting(E_ALL);
ini_set('display_errors', true);
echo 'phpversion: ', phpversion(), "
";
echo 'uname: ', php_uname("s r"), "
"; // name/release of the operating system
echo 'sapi: ', php_sapi(), "
";

echo $file, file_exists($file) ? ' exists' : ' does not exist', "
";
echo $file, is_readable($file) ? ' is readable' : ' is NOT readable', "
";
echo $file, is_writable($file) ? ' is writable' : ' is NOT writable', "
";

$fp = fopen($file, 'a+');
if ( !$fp ) {
  echo 'last error: ';
  var_dump(error_get_last());
}
else {
  echo "ok.
";
}

print?

see also: http://docs.php.net/error_get_last


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...