找到你要的答案

Q:Blank output with system function

Q:带系统功能的空白输出

When I execute my script with console "php5 -f myfile.php" I have output, But when I open it with browser I see nothing.

<?php

 $cmd=system("cat /root/pays.log |awk '{print $4}' |uniq");
 echo $cmd;

?>

当我执行我的脚本主机PHP5 F Myfile. php“我有输出,但是当我打开它的浏览器,我什么也看不见。

<?php

 $cmd=system("cat /root/pays.log |awk '{print $4}' |uniq");
 echo $cmd;

?>
answer1: 回答1:

Most likely your web-server user doesn't have access to the **root* folder. try to move pays.log to a location which your web-server can get into. also make sure the correct permission is applied on the file itself as well.

Most likely your web-server user doesn't have access to the **root* folder. try to move pays.log to a location which your web-server can get into. also make sure the correct permission is applied on the file itself as well.

answer2: 回答2:

The most likely answer is that the system() function is disabled.

There are two possible reasons for this.

  1. The safe mode is active
  2. The function is in the list of disabled functions

You can check the if the safe mode is active by ini_get('safe_mode'). That gives you a 0 if it is not active. More information here: PHP: safe-mode

The disabled functions are also a ini value. You can fetch it by ini_get('disable_functions'). It contains a comma separated list of the disabled functions. If system is inside the list, it will not work. More information here: PHP: disable-functions

It is pretty common for functions like system to be disabled.

最可能的答案是,system()功能被禁用。

有两个可能的原因。

  1. The safe mode is active
  2. The function is in the list of disabled functions

你可以检查如果安全模式是积极的ini_get('safe_mode”)。这给你一个0,如果它不活跃。更多信息:PHP安全模式

残疾人的功能也是一个初始值。你可以把它ini_get('disable_functions”)。它包含一个逗号分隔的禁用函数列表。如果系统在列表中,它将无法工作。更多信息:PHP:禁用功能

这是相当常见的功能,如系统被禁用。

php