PHP/resource: Difference between revisions
from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Created page with "==About== In PHP, a "resource" represents an opaque internal class for handling certain types of I/O-ish operations. Tentatively, variables may be declared to be of type..." |
No edit summary |
||
| Line 1: | Line 1: | ||
==About== | ==About== | ||
In [[PHP]], a "resource" | In [[PHP]], a "resource" value is an opaque internal pointer for handling certain types of I/O-ish operations. As of PHP 8.5, although "resource" is "[https://www.php.net/manual/en/reserved.other-reserved-words.php soft-reserved] and is used as a documentation pseudotype, there is no actual "resource" type; the only type which is currently known to be compatible with resource variables is "[https://www.php.net/manual/en/language.types.mixed.php <code>mixed</code>]". PHP currently interprets invocation of "<code>resource</code>" as a type as a reference to an unknown class named "{{fmt/arg|current namespace}}<code>\resource</code>". | ||
Note that additional [https://www.php.net/manual/en/book.stream.php stream] resource types can be defined in code with [https://www.php.net/manual/en/function.stream-wrapper-register.php <code>stream_wrapper_register()</code>]. | |||
==Functions== | |||
* [https://www.php.net/manual/en/function.get-resource-id.php <code>get_resource_id()</code>] | |||
* [https://www.php.net/manual/en/function.get-resource-type.php <code>get_resource_type()</code>] | |||
* [https://www.php.net/manual/en/function.is-resource.php <code>is_resource()</code>] | |||
==Links== | ==Links== | ||
===Reference=== | ===Reference=== | ||
* [https://www.php.net/manual/en/language.types.resource.php Resources] | * [https://www.php.net/manual/en/language.types.resource.php Resources] | ||
** [https://www.php.net/manual/en/resource.php List of Resource Types] | ** [https://www.php.net/manual/en/resource.php List of Resource Types] | ||
Revision as of 23:02, 25 December 2025
About
In PHP, a "resource" value is an opaque internal pointer for handling certain types of I/O-ish operations. As of PHP 8.5, although "resource" is "soft-reserved and is used as a documentation pseudotype, there is no actual "resource" type; the only type which is currently known to be compatible with resource variables is "mixed". PHP currently interprets invocation of "resource" as a type as a reference to an unknown class named "Template:Fmt/arg\resource".
Note that additional stream resource types can be defined in code with stream_wrapper_register().
