Closed peter279k closed 4 years ago
As title, please look at following code about getFileContent method implementation approach:
getFileContent
....... 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.
file_get_contents
function_exists
To improve this approach, please consider following code:
...... return file_get_contents($filename); .......
I'm not sure but maybe sometimes file_get_contents might not be available eg on certain hosters etc?
Hi @tsteur, thanks for your reply. I agree with your point. And it can stay these codes.
Closed.
As title, please look at following code about
getFileContent
method implementation approach:It looks like the
file_get_contents
will be included on PHP version and it seems that using thefunction_exists
is unnecessary.To improve this approach, please consider following code: