PHP does not support executing cmd command line

Release: 2023-02-28 09:48:01
Original
3922 people have browsed it

PHP does not support executing cmd command line

php不支持执行cmd命令行是因为你没有关闭php配置文件中的安全模式。

在php.ini文件中配置safe_mode参数支持命令执行的方法:

首先,打开php.ini,关掉安全模式safe_mode = off,然后禁用函数列表 disable_functions = proc_open, popen, exec, system, shell_exec ,把exec去掉。

示例:

php代码:

<?php
exec("mkdir d:\\test",$out);
print_r($out);
?>
Copy after login

执行该php文件,会发现在d盘下多了一个test文件夹。

参考文档:

exec函数解析

exec语法: string exec(string command, string [array], int [return_var]);

exec返回值: 字符串

exec参数说明

Command – 需要执行的命令

Array –  是输出值

return_var –是返回值0或1,如果返回0则执行成功,返回1则执行失败。

exec不成功,调试方案

推荐:php服务器

The above is the detailed content of PHP does not support executing cmd command line. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!