Possible Duplicate:
How to check if a PHP stream resource is readable or writable?
Does PHP provide any function to check the access mode of file handle? Suppose I opened a file in read only mode.
$file_handle = fopen('putty.log','r');
Can I check a particular handle's access mode in code?
A possible solution to find the mode:
Use function stream_get_meta_data:
$file_handle = fopen('putty.log','r');
$metadata = stream_get_meta_data($file_handle);
echo $metadata['mode'];
For more on the array returned read the manual.