-
Notifications
You must be signed in to change notification settings - Fork 1
Stream: detach Example
Terry L edited this page Jun 20, 2020
·
2 revisions
Shieldon\Psr7\Stream
Separates any underlying resources from the stream. After the stream has been detached, the stream is in an unusable state.
-
return
resource|null
Example:
$stream = new Stream(fopen('php://temp', 'r+'));
/* ... do something ... */
$legacy = $stream->detach();
if (is_resouce($legacy)) {
echo 'Resource is detached.';
}
// Outputs: Resource is detached.
$legacy = $stream->detach();
if (is_null($legacy)) {
echo 'Resource has been null.';
}
// Outputs: Resource has been null.
composer require shieldon/psr-http
Shieldon PSR HTTP implementation written by Terry L. from Taiwan.