如何检索PHP exec()错误响应? [英] How to retrieve PHP exec() error responses?

查看:166
本文介绍了如何检索PHP exec()错误响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我尝试执行的命令,但没有成功:

Below is the command I tried executing, without success:

exec('ln -s ' . PLUGIN_DIR . '/.htaccess ' . ABSPATH . '/.htaccess');

在最后添加die()时,它会发现存在错误:

When you add a die() at the end, it catches that there's an error:

exec('ln -s ' . PLUGIN_DIR . '/.htaccess ' . ABSPATH . '/.htaccess') or die('what?!');

对于上面的exec()语句,权限问题导致了该错误,但是PHP没有显示它.您如何从PHP显示发生了什么错误?

For the above exec() statement, a permissions problem is causing the error, but PHP isn't displaying it. How do you display from PHP what error is occurring?

推荐答案

您可以收到 exec函数,通过传递一个可选的第二个参数:

You can receive the output result of the exec function by passing an optional second parameter:

exec('ln -s ' . PLUGIN_DIR . '/.htaccess ' . ABSPATH . '/.htaccess',$output);
var_dump($output);

这篇关于如何检索PHP exec()错误响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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