Home > Backend Development > PHP Tutorial > ​php无法执行system()函数怎么办?

​php无法执行system()函数怎么办?

PHPz
Release: 2020-06-24 14:07:00
Original
3866 people have browsed it

​php无法执行system()函数怎么办?

php无法执行system()函数怎么办?

php无法执行system()函数的问题分析

PHP无法执行system()函数,可能有以后几种可能。

首先请开启错误时数,根据错误才好判断原因:打开php.ini中的 display_errors = On

在ISAPI模式下修改php.ini要重启WEB服务。

错误分析:

1、Warning: system() has been disabled for security reasons

该错误是由于服务器安全配置将system函数关闭了,编辑php.ini查找 disable_functions 将等号后面的 system 去掉即可。

2、Warning: system() [function.system]: Unable to fork

该错误是由于当前站点的运行帐号无法访问cmd.exe,找到windows\system32\cmd.exe 属性,安全,添加当前站点的运行帐号权限,或 users组权限即可。

3、在web访问下执行没有任何响应也不报错,使用php cli命令行执行却可以正常返回结果

该错误一般由于WINDOWS系统路径引起,你的程序中大概使用了绝对路径去访问程序比如:

system('D:\server\DLL\IECapt.exe --url=http://tech.cncms.com --out="D:\web\tt.fei.cn\htdocs\ttt\tech.png"');
Copy after login

此时用命令行执行结果OK,但用WEB访问就是空白也没错误。

修正方法,将文件的访问路径改为相对即可:

将IECapt.exe 复制到你的站点程序当前目录下,并将代码改为:

system('IECapt.exe --url=http://www.baidu.com --out=t/tech.png');
Copy after login

再次访问页面,OK,结果出来了。

更多相关知识,请访问PHP中文网

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template