# `gettype` and resources

> Section in “New and Extended Functionality › Language Features” of the book [PHP 7 Explained](https://php7explained.com/) by Sebastian Bergmann and Stefan Priebsch, published by thePHP.cc. The book covers PHP 7.0 to 7.4 and was last updated in November 2020. HTML version: <https://php7explained.com/new-and-extended-functionality/language-features/gettype-and-resources/>

PHP’s `gettype()` function can be used to query the current type of a variable. Prior to PHP 7.2, there was no information kept on resources after they got closed. So any attempt to fetch the type of a variable holding a closed resource simply returned `unknown type`. Since PHP 7.2, the information is kept and consequentially the type is now returned as `resource (closed)`.

---

Previous: [get_mangled_object_vars()](https://php7explained.com/new-and-extended-functionality/language-features/get_mangled_object_vars/index.html.md) | Next: [Custom Object Serialization](https://php7explained.com/new-and-extended-functionality/language-features/custom-object-serialization/index.html.md)
