Home  >  Article  >  Backend Development  >  What to do if the command line cannot be executed under php7

What to do if the command line cannot be executed under php7

王林
王林Original
2021-09-28 17:50:553605browse

php7下命令行无法执行的解决方法:1、打开php.ini配置文件;2、关闭安全模式;3、禁用函数列表“disable_functions = proc_open,shell_exec”即可。

What to do if the command line cannot be executed under php7

本文操作环境:windows10系统、php 7、thinkpad t480电脑。

php7下无法执行cmd命令行的原因是我们没有关闭php.ini配置文件中的安全模式,只要将安全模式关闭就可以了。

接下来我们一起来看看具体步骤:

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

首先打开php.ini;

然后关掉安全模式safe_mode = off;

最后禁用函数列表 disable_functions = proc_open, popen, exec, system, shell_exec ,把exec去掉。

示例:

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

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

相关介绍:

PHP(PHP: Hypertext Preprocessor)即“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法学习了C语言,吸纳Java和Perl多个语言的特色发展出自己的特色语法,并根据它们的长项持续改进提升自己,例如java的面向对象编程,该语言当初创建的主要目标是让开发人员快速编写出优质的web网站。PHP同时支持面向对象和面向过程的开发,使用上非常灵活。

推荐学习:php培训

The above is the detailed content of What to do if the command line cannot be executed under php7. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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