If I require a file in the parent page, do I need to require it again
in a child page called via Ajax in order to use it there?
Logic says that I do, but I'm getting an error that says:
Fatal error: Cannot redeclare xml2array() (previously declared in /
home/mydomain/public_html/includes/inc.xml2array.php:3)
TIA,
Jason
I'm still not sure of the answer, but for any future reader with a
similar error, using require_once() instead of require() solved the
problem.
- J
Hi,
You are asking a PHP question in a javascript group.
Don't. ;-)
For your information:
In PHP:
require(file): Includes the file and generates an error if it fails. (As
opposed to include()).
require_once(file): Includes the file ONLY if it hasn't been included
before. If it has been included before, this statement is ignored.
Apparantly you try to include the same file two times, and thus
redeclared xml2array, what generated the error.
It is better to fix your code in a serious way (= remove the second
require()), and not use require_once() to fix the problem.
For more information try comp.lang.php
Regards,
Erwin Moller
--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
Ajax always makes it difficult to know where to ask these questions.
Had I asked this question in comp.lang.php, they would have said that
it's an Ajax question so it would belong in comp.lang.javascript.
We need an Ajax-specific NG.
> On Nov 24, 5:55 am, Erwin Moller wrote:
>> Jason Carlton schreef:
>> > On Nov 23, 7:10 pm, Jason Carlton <jwcarl...@gmail.com> wrote:
>> >> Fatal error: Cannot redeclare xml2array() (previously declared in /
>> >> home/mydomain/public_html/includes/inc.xml2array.php:3)
>> [...]
>>
>> > I'm still not sure of the answer, but for any future reader with a
>> > similar error, using require_once() instead of require() solved the
>> > problem.
>>
>> [...]
>> You are asking a PHP question in a javascript group.
>> Don't. ;-)
>
> Ajax always makes it difficult to know where to ask these questions.
> Had I asked this question in comp.lang.php, they would have said that
> it's an Ajax question so it would belong in comp.lang.javascript.
Had you gotten yourself informed before posting what "Ajax" really is (and
read the error message carefully to begin with), you could have broken it
down for them to the PHP issue that it is. Besides, I do not think people
in comp.lang.php are so stupid not to see that it is a PHP problem, and you
should not assume that they are.
> We need an Ajax-specific NG.
We don't.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)