Php功能运行两次,为什么? [英] Php function run twice, why?
问题描述
以下脚本生成两个文件副本。 (我希望在我的$ wrk_dir中创建一个新的
文件)
在没有Apache的情况下执行的相同脚本正常工作并生成
单个文件副本。
定义$ URL_CSS_正常工作。 (第13行)
删除第15行正常工作。
Apache似乎执行两次脚本,第二次在后台执行。我
不要
理解为什么。
< ;?
$ id = uniqid(''bug'');
$ wrk_dir =''''; //工作目录
$ src_file =''grab.jpg''; //源文件
$ dst_file =''tmpgrab _''。$ id。''。jpg''; //新文件
echo''源文件=''。$ src_file。''< br />''; //打印源文件
名称
echo''目标文件=''。$ dst_file。''< br />''; //打印目的地
文件名
if(!copy($ wrk_dir。$ src_file,$ wrk_dir。$ dst_file)){
echo''无法复制。< br />'';
}
// $ URL_CSS _ =''string'';
?>
< link rel =" stylesheet" HREF ="< = $ URL_CSS _>?"类型= QUOT;文本/ CSS" />
测试:
Php 5.0.1 - 4.3.9 - 4.3.4
在Linux系统上,内核2.4,2.6
在Windows中似乎工作正常。 (未亲自测试)
任何想法?
The following script generates two files copies. (I expect that a new
file is created in my $wrk_dir)
The same script executed without Apache works properly and generates
single file copy.
With $URL_CSS_ defined works properly. (row 13)
Deleting row 15 works properly.
Apache seems to execute twice the script, second in background. I
don''t
understand why.
<?
$id = uniqid(''bug'');
$wrk_dir = ''''; // Working Directory
$src_file = ''grab.jpg''; // Source File
$dst_file = ''tmpgrab_''.$id.''.jpg''; // New File
echo ''Source File =''.$src_file.''<br />''; // Print Source File
Name
echo ''Destination File =''.$dst_file.''<br />''; // Print Destination
File Name
if (!copy($wrk_dir.$src_file, $wrk_dir.$dst_file)) {
echo ''Failed to copy.<br />'';
}
//$URL_CSS_=''string'';
?>
<link rel="stylesheet" href="<?=$URL_CSS_?>" type="text/css" />
Tested with:
Php 5.0.1 - 4.3.9 - 4.3.4
On Linux System, kernel 2.4, 2.6
In Windows seems to work properly. (not tested personally)
Any ideas?
推荐答案
wrk_dir)
在没有Apache的情况下执行的相同脚本正常工作并生成
单个文件副本。
使用
wrk_dir)
The same script executed without Apache works properly and generates
single file copy.
With
URL_CSS_已定义的工作正常。 (第13行)
删除第15行正常工作。
Apache似乎执行两次脚本,第二次在后台执行。我是b $ b不要
理解为什么。
< ;?
URL_CSS_ defined works properly. (row 13)
Deleting row 15 works properly.
Apache seems to execute twice the script, second in background. I
don''t
understand why.
<?
>
id = uniqid(''bug'');
id = uniqid(''bug'');
这篇关于Php功能运行两次,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!