Created
September 12, 2012 04:57
-
-
Save s-hiroshi/3704377 to your computer and use it in GitHub Desktop.
PHP > file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ファイルの権限(パーミッション)を表示する | |
<?php | |
$data = array( | |
'file' => 'sample.txt', | |
); | |
if (file_exists($data['file'])) { | |
$data['exists'] = 'exists'; | |
} else { | |
$data['exists'] = 'no exists'; | |
} | |
if (is_readable($data['file'])) { | |
$data['readable'] = 'readable'; | |
} else { | |
$data['readable'] = 'no readable'; | |
} | |
if (is_writable($data['file'])) { | |
$data['writable'] = 'writable'; | |
} else { | |
$data['writable'] = 'no writable'; | |
} | |
if (is_executable($data['file'])) { | |
$data['execute'] = 'executable'; | |
} else { | |
$data['execute'] = 'no executable'; | |
} | |
var_dump($data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ 1347425170.002] | |
[ 1347425190.361] | |
[ 1347425207.422] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$filename = 'sample.txt'; | |
if (file_exists($filename) && !is_writable($filename) | |
|| !is_writable(dirname($filename))) { | |
echo "Error"; | |
} | |
$fp = fopen($filename, 'a') or dir('ファイルを開けません'); | |
fwrite($fp, sprintf("[%' 15.3f]" . "\n", microtime(true))); | |
fclose($fp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment