/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Fatal error: Cannot redeclare readFile() line 74

i didn’t think I was redeclaring? I though I was running a callback? Which line did I smudge and why?

[code=php]
function readFile($filename) {

//is variable a resource?
if (!is_resource($filename)) {
if (!$file = fopen($filename, ‘r’)) {
return false;
} else {
$file = $filename;
}

//set variables
$ret=array(); $key=”; $val=null; $mod=0;

while (!feof($file)) {
$b = fread($file,1);
if (ord($b) < 9) {

if ($val!=null) {
if ($mod==2) { $val=(int) $val; }
if ($mod==3) { $val=(string) $val; }

$ret[$key] = $val; $key = ”; $val = null; $mod = 0;

} else {
if (ord($b) == 0) {
$mod = 0;
} elseif (ord($b) == 1) {
return $ret;
} else {
if ($mod == 5) { $key = (string) $key; }
if ($mod == 6) { $key = (int) $key; $mod = ord($b); }
}
}

} else {
if ($mod == 5 || $mod == 5) {
$key .= $b;
} elseif ($mod==0) {
$val = readFile($file);
} else
$val .= $b;
}
}
}
if (!is_resource($filename)) fclose($file);
return $ret;
}
[/code]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @ehime spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...