Skip to content

Instantly share code, notes, and snippets.

Created November 23, 2016 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7b22c14390d3e831a8d472aad00baeee to your computer and use it in GitHub Desktop.
Save anonymous/7b22c14390d3e831a8d472aad00baeee to your computer and use it in GitHub Desktop.
php 7.0.12 stream with fopen url error
<?php
ini_set('display_errors', 'on');
// Example class : http://php.net/manual/en/function.stream-filter-register.php#example-4575
class strtoupper_filter extends php_user_filter {
function filter($in, $out, &$consumed, $closing)
{
while ($bucket = stream_bucket_make_writeable($in)) {
$bucket->data = strtoupper($bucket->data);
$consumed += $bucket->datalen;
stream_bucket_append($out, $bucket);
}
return PSFS_PASS_ON;
}
}
stream_filter_register('strtoupper', 'strtoupper_filter');
#$fp = fopen(__DIR__ . '/test.txt', 'r'); # WORKS
$fp = fopen('http://localhost/test.txt', 'r'); # DOES NOT WORK
stream_filter_append($fp, 'strtoupper', STREAM_FILTER_READ); # DOES NOT WORK
#stream_filter_append($fp, 'string.toupper', STREAM_FILTER_READ); # WORKS
fpassthru($fp);
fclose($fp);
This is a text file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment