Alleged Re-Declaration of function in PHP -
i'm getting php fatal error:
fatal error: cannot redeclare getstring() (previously declared in path/src/scripts/php/functions.php:66) in path/src/scripts/php/functions.php on line 111
these files included:
- index.php "is" page
- functions.php called index.php via
require_once
. includes functions , stuff - error.php called functions.php when error in given function appears. error.php calls functions.php, via
require_once
, in case should not call functions.php second time
i know error means. function declared once. also, error occurs when call in function within functions.php.
here function:
function getstring($key, $lang) { if (!is_string($key) || !is_string($lang)) { $fehlercode = "stringnostring"; require_once ("path/src/logs/error.php"); exit; } $urkey = $key; $key = (string) $key; if (strlen($key) < 5) { switch (strlen($key)) { case 4: $key = "0".$key; break; case 3: $key = "00".$key; break; case 2: $key = "000".$key; break; case 1: $key = "0000".$key; break; default: break; } } global $de_array, $en_array; if ($lang == "en") { if (array_key_exists($key, $en_array)) { return $en_array[$key]; } else { $fehlercode = "nostringon(".$key."en)"; require_once ("path/src/logs/error.php"); exit; } } else { if (array_key_exists($key, $de_array)) { return $de_array[$key]; } else { $fehlercode = "nostringon(".$key."de)"; require_once ("path/src/logs/error.php"); exit; } } }
it works, when call in index.php this:
<? echo getstring("00004", $preflang); ?>
but doesn't work, when call function within function in functions.php this:
$faqs = '<div class="zweispaltigez"><div class="left"><h3>'.getstring("00087", $preflang).'</h3><ol>'.$questions.'</ol></div><div class="right"><h3>'.getstring("00088", $preflang).'</h3>'.$answers.'</div></div>'; return $faqs;
there nothing wrong function calling getstring()
, because when replace hardcoded text, works.
edit
i "solved" fatal error removing code calls error.php , exits
. however, now, getstring() function still doesn't function properly. calling directly index.php (like above) works fine, calling within function leads no output @ all.
Comments
Post a Comment