Built In Types: Resources
A resource is a descriptor to some sort of external entity. (Examples include files, databases, and sockets.) Resources are only created or consumed by the implementation; they are never created or consumed by Hack code. Each distinct resource has a unique ID of some unspecified form.
When scripts execute in a mode having a command-line interface, the following resources that correspond to file streams are automatically opened at program start-up:
HH\\stdin()
orHH\\try_stdin()
, which map to standard inputHH\\stdout()
orHH\\try_stdout()
, which map to standard outputHH\\stderr()
orHH\\try_stderr()
, which map to standard error
These streams have some unspecified type, which behaves like a subtype of type resource
.
The try
variants return null when executed without a command-line interface,
while the non-try
functions throw an exception.
Resources are a carryover from PHP, and their use is discouraged in Hack code.
Thank You!
Thank You! If you'd like to share more feedback, please file an issue.