PHP 5函数重新声明错误 [英] PHP 5 function redeclared error

查看:61
本文介绍了PHP 5函数重新声明错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在Win XP(SP2)上使用PHP 5.0.1和Apache 2.


我的index.php文件有require_once内容.php以及

functions.php。

我的contents.php文件还有一个require_once for functions.php。


在一台机器上测试此代码时,它可以正常工作。但是在

另一台具有相同配置的机器上(相同的PHP 5.0.1,XP + SP2,

Apache 2),会出现一条错误消息:

test_timeout函数重新声明。

(test_timeout函数在functions.php文件中。)


我们用PHP 5.0.3测试了它 - 同样的问题发生了。


为了运行PHP,MySQL,Apache组合,我们的设置步骤是:

1.安装PHP - 自定义.ini文件

2.安装MySQL

3.安装Apache - 自定义httpd.conf以使用PHP

4.从... \ php \\复制libmysql.dll \\ dir to windows \ system32 dir


两台机器的配置完全相同。两台机器

具有相同的PHP,MySQL和Apache物理目录路径。

php.ini和httpd.conf(用于apache)从机器1复制到

机器2.我们正在使用localhost在本地测试代码。


任何人都可以提供一些关于这个问题的可能原因的暗示。我在这里错过了什么吗?


谢谢,

Saayan


文件位置


home / index.php

home / secure / contents.php

home / secure / functions.php

$ index.php中的b $ b:

// blah blah

require_once(" secure / contents.php");

// blah blah

require_once(" secure / functions.php");


in contents.php:

// blah blah

require_once(" functions.php");

// blah blah

Hi,
I am using PHP 5.0.1 with Apache 2 on Win XP (SP2).

My index.php file has require_once contents.php and also for
functions.php.
My contents.php file also has a require_once for functions.php.

When this code is tested on one machine, it works fine. However on
another machine with identical configuration (same PHP 5.0.1, XP+SP2,
Apache 2), an error message appears :
test_timeout function redeclared.
(test_timeout function is in functions.php file.)

We have tested it with PHP 5.0.3 - same problem happens.

For running the PHP, MySQL, Apache combination, our setup steps are:
1. Install PHP - customize the .ini file
2. Install MySQL
3. Install Apache - customize the httpd.conf for using PHP
4. Copy libmysql.dll from ...\php\ dir to windows\system32 dir

The configurations are exactly same for both machines. The two machines
have identical PHP, MySQL and Apache physical directory paths. The
php.ini and httpd.conf (for apache) are copied from machine 1 to
machine 2. And we are testing the code locally using localhost.

Can anyone please give some hint as to the possible cause of this
problem. Am I missing something here?

Thanks,
Saayan

The file locations

home/index.php
home/secure/contents.php
home/secure/functions.php

in index.php:
// blah blah
require_once("secure/contents.php");
// blah blah
require_once("secure/functions.php");

in contents.php:
// blah blah
require_once("functions.php");
// blah blah

推荐答案

2005年1月11日09:01:09 -0800, sa****@farfence.com 写道:
On 11 Jan 2005 09:01:09 -0800, sa****@farfence.com wrote:

我在Win XP(SP2)上使用PHP 5.0.1和Apache 2.

我的index.php文件有require_once contents.php以及
functions.php。
我的contents.php文件还有一个require_once for functions.php。

当这段代码是在一台机器上测试,它工作正常。但是在另一台具有相同配置的机器上(相同的PHP 5.0.1,XP + SP2,Apache 2),会出现一条错误消息:
test_timeout函数已重新声明。
(test_timeout函数在functions.php文件中。)

我们用PHP 5.0.3测试过它 - 同样的问题发生了。

运行PHP,MySQL,Apache组合,我们的设置步骤是:
1。安装PHP - 自定义.ini文件
2。安装MySQL
3。安装Apache - 自定义httpd.conf以使用PHP
4。将libmysql.dll从... \php \目录复制到windows \ system32目录

两台计算机的配置完全相同。这两台机器具有相同的PHP,MySQL和Apache物理目录路径。
php.ini和httpd.conf(用于apache)从机器1复制到机器2.我们正在使用localhost在本地测试代码。

任何人都可以请对这个问题的可能原因给出一些暗示。我在这里遗漏了什么吗?

谢谢,
Saayan

文件位置

home / index.php
home /secure/contents.php
home / secure / functions.php
在index.php中:
// blah blah
require_once(" secure / contents。 php");
// blah blah
require_once(" secure / functions.php");

in contents.php:
// blah blah
require_once("functions.php");
// blah blah
Hi,
I am using PHP 5.0.1 with Apache 2 on Win XP (SP2).

My index.php file has require_once contents.php and also for
functions.php.
My contents.php file also has a require_once for functions.php.

When this code is tested on one machine, it works fine. However on
another machine with identical configuration (same PHP 5.0.1, XP+SP2,
Apache 2), an error message appears :
test_timeout function redeclared.
(test_timeout function is in functions.php file.)

We have tested it with PHP 5.0.3 - same problem happens.

For running the PHP, MySQL, Apache combination, our setup steps are:
1. Install PHP - customize the .ini file
2. Install MySQL
3. Install Apache - customize the httpd.conf for using PHP
4. Copy libmysql.dll from ...\php\ dir to windows\system32 dir

The configurations are exactly same for both machines. The two machines
have identical PHP, MySQL and Apache physical directory paths. The
php.ini and httpd.conf (for apache) are copied from machine 1 to
machine 2. And we are testing the code locally using localhost.

Can anyone please give some hint as to the possible cause of this
problem. Am I missing something here?

Thanks,
Saayan

The file locations

home/index.php
home/secure/contents.php
home/secure/functions.php

in index.php:
// blah blah
require_once("secure/contents.php");
// blah blah
require_once("secure/functions.php");

in contents.php:
// blah blah
require_once("functions.php");
// blah blah




没什么看似明显错的......


这是Windows,因此文件名中的差异可能是一个问题? (我不能

重现这个问题)。


你说配置是一样的 - 如果你没有说php.ini相同的我会

想知道这两个电话之间是否存在一个包含路径问题以某种方式获取不同的

functions.php?


你能否证明它失败了,例如通过在functions.php中使用虚函数设置那个

目录结构的迷你版本,并从命令行运行它?
命令行?例如这里没有失败:


D:\public_html \ php_usenet \require_once> type index.php

<?php

print __FILE __。" \ n" ;;

require_once(''secure / contents.php'');

require_once(''secure /functions.php'');

?>

D:\public_html \ php_usenet \require_once>输入secure\contents.php

<?php

print __FILE __。" \ n" ;;

require_once(''secure / functions.php'');

?>

D:\public_html \ php_usenet \require_once>输入secure\functions.php

<?php

print __FILE __。" \ n" ;;

函数x()

{

print" x" ;;

}

?>

D:\public_html \ php_usenet \require_once> d:\ php-5.0.3- Win32\php.exe -q index.php

D:\public_html \ php_usenet \ quire_once\index.php

D:\public_html\php_usenet\require_once\secure\cont ents.php

D:\public_html \ php_usenet \require_once\secure\func tions.php

-

Andy Hassall /< an ** @ andyh.co.uk> /< http://www.andyh.co.uk>

< http://www.andyhsoftware.co.uk/space>空间:磁盘使用情况分析工具



Nothing looks obviously wrong...

It''s Windows so differences in filename case might be an issue? (I can''t
reproduce the issue though).

You say the configs are the same - if you hadn''t said php.ini is identical I''d
wonder if it''s an include_path issue somehow picking up a different
functions.php between the two calls?

Can you demonstrate it failing, e.g. by setting up mini versions of that
directory structure with a dummy function in functions.php, and running it from
the command line? e.g. here''s it not failing:

D:\public_html\php_usenet\require_once>type index.php
<?php
print __FILE__ ."\n";
require_once(''secure/contents.php'');
require_once(''secure/functions.php'');
?>
D:\public_html\php_usenet\require_once>type secure\contents.php
<?php
print __FILE__ ."\n";
require_once(''secure/functions.php'');
?>
D:\public_html\php_usenet\require_once>type secure\functions.php
<?php
print __FILE__ ."\n";
function x()
{
print "x";
}
?>
D:\public_html\php_usenet\require_once>d:\php-5.0.3-Win32\php.exe -q index.php
D:\public_html\php_usenet\require_once\index.php
D:\public_html\php_usenet\require_once\secure\cont ents.php
D:\public_html\php_usenet\require_once\secure\func tions.php

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool


< sa **** @ farfence.com>在消息中写道

news:11 ********************** @ z14g2000cwz.googlegr oups.com ...
<sa****@farfence.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...

我在Win XP(SP2)上使用PHP 5.0.1和Apache 2.

我的index.php文件有require_once contents.php和
functions.php。
我的contents.php文件还有一个require_once for functions.php。

当这个代码在一台机器上测试时,它运行正常。但是在另一台具有相同配置的机器上(相同的PHP 5.0.1,XP + SP2,Apache 2),会出现一条错误消息:
test_timeout函数已重新声明。
(test_timeout函数在functions.php文件中。)

我们用PHP 5.0.3测试过它 - 同样的问题发生了。

运行PHP,MySQL,Apache组合,我们的设置步骤如下:
1.安装PHP - 自定义.ini文件
2.安装MySQL
3.安装Apache - 自定义httpd.conf以使用PHP
4.复制libmysql .dll来自... \php \ dir到windows \ system32 dir

两台机器的配置完全相同。这两台机器具有相同的PHP,MySQL和Apache物理目录路径。
php.ini和httpd.conf(用于apache)从机器1复制到机器2.我们正在使用localhost在本地测试代码。

任何人都可以请对这个问题的可能原因给出一些暗示。我在这里遗漏了什么吗?

谢谢,
Saayan

文件位置

home / index.php
home /secure/contents.php
home / secure / functions.php
在index.php中:
// blah blah
require_once(" secure / contents。 php");
// blah blah
require_once(" secure / functions.php");

in contents.php:
// blah blah
require_once(" functions.php");
// blah blah
Hi,
I am using PHP 5.0.1 with Apache 2 on Win XP (SP2).

My index.php file has require_once contents.php and also for
functions.php.
My contents.php file also has a require_once for functions.php.

When this code is tested on one machine, it works fine. However on
another machine with identical configuration (same PHP 5.0.1, XP+SP2,
Apache 2), an error message appears :
test_timeout function redeclared.
(test_timeout function is in functions.php file.)

We have tested it with PHP 5.0.3 - same problem happens.

For running the PHP, MySQL, Apache combination, our setup steps are:
1. Install PHP - customize the .ini file
2. Install MySQL
3. Install Apache - customize the httpd.conf for using PHP
4. Copy libmysql.dll from ...\php\ dir to windows\system32 dir

The configurations are exactly same for both machines. The two machines
have identical PHP, MySQL and Apache physical directory paths. The
php.ini and httpd.conf (for apache) are copied from machine 1 to
machine 2. And we are testing the code locally using localhost.

Can anyone please give some hint as to the possible cause of this
problem. Am I missing something here?

Thanks,
Saayan

The file locations

home/index.php
home/secure/contents.php
home/secure/functions.php

in index.php:
// blah blah
require_once("secure/contents.php");
// blah blah
require_once("secure/functions.php");

in contents.php:
// blah blah
require_once("functions.php");
// blah blah




你的require_once语句有点棘手。 contents.php实际上是加载home / functions.php的
,因为相对路径是相对于

运行脚本(home / index.php)而不是文件包含

include / require语句。



Your require_once statements are kinda screwy. contents.php is actually
loading the home/functions.php, because relative paths are relative to the
running script (home/index.php) and not the file which contains the
include/require statement.


2005年1月11日星期二18:37:17 -0500,Chung Leong < ch *********** @ hotmail.com>

写道:
On Tue, 11 Jan 2005 18:37:17 -0500, "Chung Leong" <ch***********@hotmail.com>
wrote:
home /index.php
home / secure / contents.php
home / secure / functions.php
在index.php中:
// blah blah
require_once(" secure / contents.php");
// blah blah
require_once(" secure / functions.php");

in contents.php:
// blah blah
require_once(" functions.php");
// blah blah
home/index.php
home/secure/contents.php
home/secure/functions.php

in index.php:
// blah blah
require_once("secure/contents.php");
// blah blah
require_once("secure/functions.php");

in contents.php:
// blah blah
require_once("functions.php");
// blah blah



你的require_once语句有点棘手。 contents.php实际上是加载home / functions.php,因为相对路径是相对于运行脚本(home / index.php)而不是包含
include /的文件需要声明。



Your require_once statements are kinda screwy. contents.php is actually
loading the home/functions.php, because relative paths are relative to the
running script (home/index.php) and not the file which contains the
include/require statement.



http://uk2.php.net/manual/en/function.include.php


"包含的文件首先在相对于当前

工作目录的include_path中查找,然后在相对于当前

脚本目录的include_path中查找。例如。如果你的include_path是。,当前的工作目录是/ www /,你包括/ b.php包括b.php在该文件中,b.php是/ b $ b首先在/ www /然后在/ www / include /中查找。如果文件名以../开头,

它只在相对于当前工作目录的include_path中查找。


-

Andy Hassall /< an ** @ andyh.co.uk> /< http://www.andyh.co.uk>

< http://www.andyhsoftware.co.uk/space>空间:磁盘使用情况分析工具



http://uk2.php.net/manual/en/function.include.php

" Files for including are first looked in include_path relative to the current
working directory and then in include_path relative to the directory of current
script. E.g. if your include_path is ., current working directory is /www/, you
included include/a.php and there is include "b.php" in that file, b.php is
first looked in /www/ and then in /www/include/. If filename begins with ../,
it is looked only in include_path relative to the current working directory."

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool


这篇关于PHP 5函数重新声明错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆