-
Notifications
You must be signed in to change notification settings - Fork 2
Stream: getMetadata Example
Terry L edited this page Jun 20, 2020
·
2 revisions
Shieldon\Psr7\Stream
Get stream metadata as an associative array or retrieve a specific key.
-
param
string
key= null
Specific metadata to retrieve. -
return
array|mixed|null
Example:
$resource = fopen(BOOTSTRAP_DIR . '/sample/shieldon_logo.png', 'r+');
$stream = new Stream($resource);
$meta = $stream->getMetadata();
print(print_r($queryParams, true));
/* Outputs:
Array
(
[timed_out] => false
[blocked] => true
[eof] => false
[wrapper_type] => plainfile
[stream_type] => STDIO
[mode] => r+
[unread_bytes] => 0
[seekable] => true
[uri] => /home/terrylin/data/psr7/tests/sample/shieldon_logo.png
)
*/
echo $stream->getMetadata('mode')
// Outputs: r+
composer require shieldon/psr-http
Shieldon PSR HTTP implementation written by Terry L. from Taiwan.