Skip to content

Problem about IniReader::getFileContent method implementation #12

@peter279k

Description

@peter279k

As title, please look at following code about getFileContent method implementation approach:

.......
        if (function_exists('file_get_contents')) {
            return file_get_contents($filename);
        } elseif (function_exists('file')) {
            $ini = file($filename);
            if ($ini !== false) {
                return implode("\n", $ini);
            }
        } elseif (function_exists('fopen') && function_exists('fread')) {
            $handle = fopen($filename, 'r');
            if (!$handle) {
                return false;
            }
            $ini = fread($handle, filesize($filename));
            fclose($handle);
            return $ini;
        }

        return false;
......

It looks like the file_get_contents will be included on PHP version and it seems that using the function_exists is unnecessary.

To improve this approach, please consider following code:

......
    return file_get_contents($filename);
.......

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions