I have some code that works with pipes and files. At the end of operation my function should close resource.
Can I close a pipe resource with fclose? It seems not hard for php to track how to close a resource but I see 2 functions.
I create pipe with popen function.
Otherwise I need a method to distinguish pipe and file resources.
get_resource_type returns "stream" for both resources.
Or I have to implement expensive wrapper classes.
class PipeStream {
public function __desctruct() { pclose($this->resource); }
}
class FileStream {
public function __desctruct() { fclose($this->resource); }
}