Language file declaring a function crashes
Posted by dmaftei
Language file declaring a function crashes November 08, 2007 11:11PM |
Registered: 17 years ago Posts: 10 |
Hello All,
Does anybody have any idea why a language file that defines a function (or includes another .php file) crashes? I'm experimenting with romanian.php; when I use it as is, everything is fine. But if I add a function to the file, as in:
<?php
function useless($str)
{
return str_replace("foo", "bar", $str);
}
$language="Romanian";
[snip]
then a number of pages come out blank (I noticed 'General Settings' and forum edit in the admin panel, and 'Forum Settings' in the user's control panel.) Note that I'm not even using the function, simply declaring it causes problems...
And btw, if I do use the function, it works. If I go down in the file and do something like:
[snip]
"Activity" => useless("foo bar foobar"),
[snip]
I do get "bar bar barbar" displayed for "Activity".
TIA
dmaftei
Edited 1 time(s). Last edit at 11/08/2007 11:28PM by dmaftei.
Does anybody have any idea why a language file that defines a function (or includes another .php file) crashes? I'm experimenting with romanian.php; when I use it as is, everything is fine. But if I add a function to the file, as in:
<?php
function useless($str)
{
return str_replace("foo", "bar", $str);
}
$language="Romanian";
[snip]
then a number of pages come out blank (I noticed 'General Settings' and forum edit in the admin panel, and 'Forum Settings' in the user's control panel.) Note that I'm not even using the function, simply declaring it causes problems...
And btw, if I do use the function, it works. If I go down in the file and do something like:
[snip]
"Activity" => useless("foo bar foobar"),
[snip]
I do get "bar bar barbar" displayed for "Activity".
TIA
dmaftei
Edited 1 time(s). Last edit at 11/08/2007 11:28PM by dmaftei.
Re: Language file declaring a function crashes November 09, 2007 02:54AM |
Admin Registered: 20 years ago Posts: 8,532 |
This would crash if the language file was included more than once.
Can you try the following construction?
Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Can you try the following construction?
if (! function_exists('useless')) { function useless($str) { return str_replace("foo", "bar", $str); } }
Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Language file declaring a function crashes November 09, 2007 08:56AM |
Registered: 17 years ago Posts: 10 |
Re: Language file declaring a function crashes November 09, 2007 09:08AM |
Admin Registered: 20 years ago Posts: 8,532 |
Yes, that would be the only reason for this code to crash. But I do not know why this is the case for you. On my system, the language file appears to be loaded only once.
Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Language file declaring a function crashes November 09, 2007 09:23AM |
Registered: 17 years ago Posts: 10 |
Re: Language file declaring a function crashes November 09, 2007 11:11AM |
Admin Registered: 23 years ago Posts: 4,495 |
In certain parts of the admin, it may be loaded more than once to fill in a drop down box.
Brian - Cowboy Ninja Coder - Personal Blog - Twitter
Re: Language file declaring a function crashes November 09, 2007 12:40PM |
Registered: 17 years ago Posts: 10 |
Re: Language file declaring a function crashes November 09, 2007 01:50PM |
Admin Registered: 22 years ago Posts: 9,240 |
Re: Language file declaring a function crashes November 09, 2007 02:18PM |
Registered: 17 years ago Posts: 10 |
Sorry, only registered users may post in this forum.