php不支持执行cmd命令行是因为你没有关闭php配置文件中的安全模式。
在php.ini文件中配置safe_mode参数支持命令执行的方法:
首先,打开php.ini,关掉安全模式safe_mode = off,然后禁用函数列表 disable_functions = proc_open, popen, exec, system, shell_exec ,把exec去掉。
示例:
立即学习“PHP免费学习笔记(深入)”;
php代码:
<?php exec("mkdir d:\test",$out); print_r($out); ?>
执行该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服务器
以上就是php不支持执行cmd命令行的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号