Created
November 23, 2016 14:03
-
-
Save anonymous/7b22c14390d3e831a8d472aad00baeee to your computer and use it in GitHub Desktop.
php 7.0.12 stream with fopen url error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is a text file. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment