I have a peculiar bug in my PHP code. It looks something like this:
Fatal error: Cannot redeclare func_name() (previously declared in
script.php:57) in script.php on line 57
I've done a search and determined that "func_name" really is unique.
Besides, how is this even possible? It was previously declared on the
same line it's declared?
Any help is appreciated. Thank you! 5 3622
Are you accidentally including the same file more than once?
"Just Another Victim of the Ambient Morality" <ih*******@hotmail.comwrote
in message news:Pz*********************@fe09.news.easynews.co m...
I have a peculiar bug in my PHP code. It looks something like this:
Fatal error: Cannot redeclare func_name() (previously declared in
script.php:57) in script.php on line 57
I've done a search and determined that "func_name" really is unique.
Besides, how is this even possible? It was previously declared on the
same line it's declared?
Any help is appreciated. Thank you!
"Tim McGurk" <ti*******@yahoo.comwrote in message
news:O5******************************@giganews.com ...
Are you accidentally including the same file more than once?
"Just Another Victim of the Ambient Morality" <ih*******@hotmail.com>
wrote in message news:Pz*********************@fe09.news.easynews.co m...
> I have a peculiar bug in my PHP code. It looks something like this:
Fatal error: Cannot redeclare func_name() (previously declared in script.php:57) in script.php on line 57
I've done a search and determined that "func_name" really is unique. Besides, how is this even possible? It was previously declared on the same line it's declared? Any help is appreciated. Thank you!
Thank you for the quick reply!
I don't think I'm including it more than once.
Actually, what I'm doing is this:
function func($input)
{
function func_name($e)
{
return $e + 1;
}
return array_map('func_name', $input);
}
This appears to be what's causing the error.
I would have guessed that it was okay but, apparently, defining
"func_name" in "func" decorates it, somehow. However, I read some
documentation saying that all function names have global scope, regardless
of where it was defined.
So, is this possibly a bug?
Thank you...
Just Another Victim of the Ambient Morality escribió:
function func($input)
{
function func_name($e)
{
return $e + 1;
}
return array_map('func_name', $input);
}
func_name() is declared when you run func(). That means that if you run
func() more than once you'll declare func_name() more than once, what is
not allowed.
Just move func_name() outside func(), I see no reason to declare it inside.
It looks like you've done lots of JavaScript stuff. Sorry, PHP is way
different.
So, is this possibly a bug?
Yes, it's a bug in your code ;-)
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
On Jul 22, 7:05*am, "Just Another Victim of the Ambient Morality"
<ihates...@hotmail.comwrote:
"Tim McGurk" <timmcg...@yahoo.comwrote in message
news:O5******************************@giganews.com ...
Are you accidentally including the same file more than once?
"Just Another Victim of the Ambient Morality" <ihates...@hotmail.com>
wrote in messagenews:Pz*********************@fe09.news.easy news.com...
* *I have a peculiar bug in my PHP code. *It looks something like this:
Fatal error: Cannot redeclare func_name() (previously declared in
script.php:57) in script.php on line 57
* *I've done a search and determined that "func_name" really is unique.
* *Besides, how is this even possible? *It was previously declared on the
same line it's declared?
* *Any help is appreciated. *Thank you!
* * Thank you for the quick reply!
* * I don't think I'm including it more than once.
* * Actually, what I'm doing is this:
function func($input)
{
* * function func_name($e)
* * {
* * * * return $e + 1;
* * }
* * return array_map('func_name', $input);
}
* * This appears to be what's causing the error.
* * I would have guessed that it was okay but, apparently, defining
"func_name" in "func" decorates it, somehow. *However, I read some
documentation saying that all function names have global scope, regardless
of where it was defined.
* * So, is this possibly a bug?
* * Thank you...
function func($input) {
if (!function_exists('func_name')) {
function func_name($e){{
return $e + 1;
}
}
return array_map('func_name', $input);
}
Try this!
greetz Alex
On Jul 22, 7:10*pm, "vette...@googlemail.com"
<vette...@googlemail.comwrote:
On Jul 22, 7:05*am, "Just Another Victim of the Ambient Morality"
<ihates...@hotmail.comwrote:
"Tim McGurk" <timmcg...@yahoo.comwrote in message
news:O5******************************@giganews.com ...
Are you accidentally including the same file more than once?
"Just Another Victim of the Ambient Morality" <ihates...@hotmail.com>
wrote in messagenews:Pz*********************@fe09.news.easy news.com....
>* *I have a peculiar bug in my PHP code. *It looks something like this:
>Fatal error: Cannot redeclare func_name() (previously declared in
>script.php:57) in script.php on line 57
>* *I've done a search and determined that "func_name" really is unique.
>* *Besides, how is this even possible? *It was previously declared on the
>same line it's declared?
>* *Any help is appreciated. *Thank you!
* * Thank you for the quick reply!
* * I don't think I'm including it more than once.
* * Actually, what I'm doing is this:
function func($input)
{
* * function func_name($e)
* * {
* * * * return $e + 1;
* * }
* * return array_map('func_name', $input);
}
* * This appears to be what's causing the error.
* * I would have guessed that it was okay but, apparently, defining
"func_name" in "func" decorates it, somehow. *However, I read some
documentation saying that all function names have global scope, regardless
of where it was defined.
* * So, is this possibly a bug?
* * Thank you...
function func($input) {
* * if (!function_exists('func_name')) {
* * * * * * * * function func_name($e){{
* * * * * * * * * * * * return $e + 1;
* * * * * * * * }
* * * * }
* * return array_map('func_name', $input);
}
Try this!
greetz Alex
function func($input) {
if (!function_exists('func_name')) {
function func_name($e) { // without double curly brackets
return $e + 1;
}
}
return array_map('func_name', $input);
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tim Tyler |
last post by:
I'm getting fatal errors when executing code - and my error handler is
failing to trap them - so I get no stack backtrace :-(
The error I am getting is:
"Fatal error: Call to a member function...
|
by: Rich |
last post by:
I am trying to obtain more debugging information for an issue I
reported (ref. Bug #37185
<http://bugs.php.net/bug.php?id=37185&edit=2>). Unfortunately, I do not
have access to the now-ancient...
|
by: TristaSD |
last post by:
Hi,
Here's a nice footer I get inside every php page I write in wwwroot on
my server. The code gets parsed just fine. I installed php5.2-win32
under W2K Server, IIS 5.0. I've installed php on...
|
by: Simon Kittle |
last post by:
Hi,
Is it possible in PHP to provide a nice pretty page when a fatal error
occurs? (Or any of the errors listed here
http://uk.php.net/manual/en/function.set-error-handler.php which you
cannot...
|
by: Midgard |
last post by:
I have this error:
Fatal error: Cannot redeclare send_welcome_mail() (previously declared in /home/oxxowhol/public_html/config.php:21) in /home/oxxowhol/public_html/config.php on line 21
Why?
|
by: Kesavan |
last post by:
I need polymorphism in php.
When I run this following code I get the following error.
Fatal error: Cannot redeclare aClass::aPrint() in C:\Program Files
\xampp\htdocs\k7\prCls.php on line 16
...
|
by: srilathaapi |
last post by:
Hi All,
I am getting the error cannot redeclare the class some xxx in
file xxx.php.
bcz i m including xxx.php in 3 diffrent functions in the same file to
invoke the 3 differnet functions in the...
|
by: srilathaapi |
last post by:
Hi All,
I am getting the error cannot redeclare the class some xxx in
file xxx.php.
bcz i m including xxx.php in 3 diffrent functions in the same file to
invoke the 3 differnet functions in the...
|
by: ann86 |
last post by:
Hello,
I am a newbie to PHP and I am working on a site that was created by someone else. The server was updated yesterday so now I am getting the error
Fatal error: Cannot redeclare...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |