Fixing broken ini_parser in PHP7

The cause if this problem is a broken brain somewhere in the PHP Developer comunity, for some reason they have removed support for using hash-marks (#) for comments in PHP 7.

Theres no valid reason for this, it’s not like that character has some other meaning now, it’s just removed. It’s also pretty arrogant to try and dictate changes like this, i do not decide what format the files i need to read are in, i just need to read them – and now i cannot do that with the built in functions and needs to use ugly hacks like this:

function real_ini_parser($file)
{
    return parse_ini_string(preg_replace('/^#.*?\n/m',
                          '',file_get_contents($file)),true);
}

Yet another reason to switch to a more modern programming language!

Dette indlæg blev udgivet i Uncategorized. Bogmærk permalinket.