Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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 假在…中是什么意思。。。如果($var!==false)_Php_Variables_If Statement_Exec_Var - Fatal编程技术网

Php 假在…中是什么意思。。。如果($var!==false)

Php 假在…中是什么意思。。。如果($var!==false),php,variables,if-statement,exec,var,Php,Variables,If Statement,Exec,Var,举个例子,如果例如启用了php exec,我可以运行这个命令:/etc/init.d/mysql restart或者我需要设置!==false至!==是否正确 $var = exec('/etc/init.d/mysql restart'); if ($var !== false) { echo "php exec is enabled"; } 基本上我想做的是,如果在服务器上启用了这个函数,从php重新启动mysql $var = exec('/etc/init.d/mysql re

举个例子,如果例如启用了php exec,我可以运行这个命令:
/etc/init.d/mysql restart
或者我需要设置
!==false
!==是否正确

$var = exec('/etc/init.d/mysql restart');

if ($var !== false) {
   echo "php exec is enabled";
}
基本上我想做的是,如果在服务器上启用了这个函数,从php重新启动mysql

$var = exec('/etc/init.d/mysql restart');

if ($var !== false) {
   exec('/etc/init.d/mysql restart');
   echo "php exec is enabled and restart mysql";
}

你是如何检查函数的,它会给你错误

$var = exec(); // need to pass an argument
要检查函数是否存在,请尝试

if(function_exists('exec')) {
    echo "php exec is enabled";
}
另外,根据更新后的代码,您需要将retrun参数传递给函数以检查返回值

exec('/etc/init.d/mysql restart', $output, $return);
// Return will return non-zero upon an error
if (!$return) {
   echo "php exec is enabled";
}
有关更多信息:-

请阅读此内容。