#2319 closed defect (bug) (fixed)
file_get_contents is PHP 4.3+, docs says PHP 4.2 ok
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | General | Version: | 2.0 |
| Severity: | blocker | Keywords: | PHP 4.2 file_get_contents |
| Cc: |
Description
cache.php uses function file_get_contents with is PHP 4.3+ when docs says that minimum requirement is 4.2
Either upgrade doc, or for maximum compatibility with obsolete install like errrr mine, add somewhere :
if (!function_exists('file_get_contents')) {
function file_get_contents($file) {
return implode('',file($file));
}
}
Change History (7)
comment:2
davidhouse — 7 years ago
comment:4
markjaquith — 7 years ago
This is what I've been using in one of my plugins... not sure where I got it:
/* compatibility with PHP versions older than 4.3 */
if ( !function_exists('file_get_contents') ) {
function file_get_contents($file) {
$file = file($file);
return !$file ? false : implode('', $file);
}
}
comment:5
markjaquith — 7 years ago
I don't think implode will return false, which is why you need that extra line
- Resolution set to fixed
- Status changed from new to closed
Note: See
TracTickets for help on using
tickets.

We could just add that into functions-compat.php. file_get_contents() is a damn useful function, and it's a lot more readable than implode(, file(...)), so a suitable compat function candidate, I think.