PHP: How to check access mode to an already open file handler?

Possible duplicate:
How to check if a PHP stream resource is writable or writable?

Does PHP provide any function for checking the mode of access to a file descriptor? Suppose I opened a file in read-only mode.

$file_handle = fopen('putty.log','r'); 

Is it possible to check the specific mode of access to the descriptor in the code?

+4
source share
1 answer

Possible solution for search mode:

Use stream_get_meta_data function:

 $file_handle = fopen('putty.log','r'); $metadata = stream_get_meta_data($file_handle); echo $metadata['mode']; 

Read more about the returned array in the manual.

+5
source

Source: https://habr.com/ru/post/1387921/


All Articles