Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php determine if a variable is an open file handle

Tags:

php

i am currently using is_resource()to determine whether a variable is an open file handle.

Is this correct or is there an alternative (better) way to do this?

like image 347
Marty Wallace Avatar asked Aug 22 '12 17:08

Marty Wallace


1 Answers

That can give you a lot of false positives, like for example database resources.

You should use get_resource_type instead.

like image 183
jeroen Avatar answered Oct 12 '22 11:10

jeroen