update page now
Longhorn PHP 2026 - Call For Papers

Voting

: four minus three?
(Example: nine)

The Note You're Voting On

Peter Baylies
12 years ago
Replacement for php_ini_string() for PHP pre 5.3 - uses php_ini_file() and streams

<?php
if ( !function_exists( 'parse_ini_string' ) ) {
    function parse_ini_string( $string, $process_sections ) {
        if ( !class_exists( 'parse_ini_filter' ) ) {
            /* Define our filter class */
            class parse_ini_filter extends php_user_filter {
                static $buf = '';
                function filter( $in, $out, &$consumed, $closing ) {
                    $bucket = stream_bucket_new( fopen('php://memory', 'wb'), self::$buf );
                    stream_bucket_append( $out, $bucket );
                    return PSFS_PASS_ON;
                }
            }
            /* Register our filter with PHP */
            stream_filter_register("parse_ini", "parse_ini_filter")
            or return false;
        }
        parse_ini_filter::$buf = $string;
        return parse_ini_file( "php://filter/read=parse_ini/resource=php://memory", $process_sections );
    }
}
?>

<< Back to user notes page

To Top