Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php fwrite to STDERR导致可执行脚本出错_Php_Fwrite_Stderr_Command Line Interface - Fatal编程技术网

Php fwrite to STDERR导致可执行脚本出错

Php fwrite to STDERR导致可执行脚本出错,php,fwrite,stderr,command-line-interface,Php,Fwrite,Stderr,Command Line Interface,我有一个奇怪的问题。只有在可执行的php脚本中才会发生这种错误,我不知道为什么 警告:fwrite()要求参数1是给定的资源字符串 我举了以下例子: -rwxr-xr-x 1 root root 87 Sep 10 16:55 test* -rw-r--r-- 1 root root 33 Sep 10 17:10 test.php 其中文件./test为: #!/usr/bin/php -q <?php fwrite(STDERR, "test\n"); #/usr/bi

我有一个奇怪的问题。只有在可执行的php脚本中才会发生这种错误,我不知道为什么

警告:fwrite()要求参数1是给定的资源字符串

我举了以下例子:

-rwxr-xr-x 1 root root    87 Sep 10 16:55 test*
-rw-r--r-- 1 root root    33 Sep 10 17:10 test.php
其中文件./test为:

#!/usr/bin/php -q
<?php
fwrite(STDERR, "test\n");
#/usr/bin/php-q

当我使用shebang
#时,错误消失了/usr/local/bin/php
。有道理,因为php是从源代码编译的


但我还是不明白为什么这会发生在另一条路上。我试着用“错误”的shebang检查phpinfo,但我仍然得到
PHP版本5.4.28
作为版本,因此没有多次安装。

有完全相同的问题。
<?php
fwrite(STDERR, "test\n");
# ./test 
<br />
<b>Warning</b>:  fwrite() expects parameter 1 to be resource, string given

# php -q test.php 
test

# php -r 'fwrite(STDERR, "test\n");'
test