Back to index

php5  5.3.10
filter_errors.inc
Go to the documentation of this file.
00001 <?php
00002 
00003 function filter_errors_skipif($needle) {
00004        if (!function_exists('fnmatch')) {
00005               die('skip fnmatch() not available');
00006        }
00007        $filters = stream_get_filters();
00008        foreach($filters as $filter) {
00009               if (fnmatch($filter, $needle)) return;
00010        }
00011        die("skip $needle not available");
00012 }
00013 
00014 function filter_errors_test($filter, $data) {
00015 
00016        echo "test filtering of buffered data\n";
00017 
00018        $stream = fopen('php://memory', 'wb+');
00019 
00020        fwrite($stream, b".\r\n$data");
00021        fseek($stream, 0, SEEK_SET);
00022        stream_get_line($stream, 8192, "\r\n");
00023 
00024        $f = stream_filter_append($stream, $filter);
00025 
00026        echo "test filtering of non buffered data\n";
00027 
00028        $stream = fopen('php://memory', 'wb+');
00029 
00030        fwrite($stream, b"$data");
00031        fseek($stream, 0, SEEK_SET);
00032 
00033        stream_filter_append($stream, $filter);
00034        stream_get_contents($stream);
00035 
00036 }
00037