Atitit.执行cmd 命令行 php
Atitit.执行cmd 命令行 php
1. 执行cmd 命令行,调用系统命令的基础 1
1.1. 实际执行模式 1
1.2. 空格的问题 1
1.3. 中文路径的问题,程序文件读取编码设置 1
1.4. 回显乱码 2
2. exec,system等函数调用系统命令 2
3. php.ini,关掉安全模式safe_mode = off 3
4. 参考 3
1. 执行cmd 命令行,调用系统命令的基础
1.1. 实际执行模式
Processmonitor 检查。得到。。
PID: 115372, Command line: cmd.exe /c "D:\workspace 绌烘?\AtiBrow\exp_receipt.bat"
1.2. 空格的问题
双引号解决
1.3. 中文路径的问题,程序文件读取编码设置
Php.ini中的default_charset = "utf-8" 只是设置post,get的编码,不能设置php文件的读取编码。。最好是注释掉此参数,让他根据文件本身的编码自动判断,否则输出的php结果都 header('Content-Type:text/html;charset=utf8
作者:: 老哇的爪子 Attilax 艾龙, EMAIL:1466519819@qq.com
原因在于php文件本身是用系统字符集来编码的,中文的windows XP都是用GB2312,每一个文件头部都有字段指示该文件是用何种方式编码的
用javac编译java源文件时,编译器默认用系统编码读源文件里的内容。如果源文件不是用系统编码来保存的,可以用命令javac -encoding指定具体的编码
淋巴,只能不个php文件的编码设置成gbk。。才ok。。
1.4. 回显乱码
header('Content-Type:text/html;charset=gbk');
2. exec,system等函数调用系统命令
这二个都是用来调用系统shell命令,
不同点:
exec可以把执行的结果全部返回到$output函数里(数组),$status是执行的状态 0为成功 1为失败
systerm不需要提供$output函数,他是直接把结果返回出来,同样$return_var是执行的状态码 0为成功 1为失败
exec示例:
1. 以下为引用的内容:
2.
3. $a = exec("dir",$out,$status);
4. print_r($a);
5. print_r($out);
6. print_r($status);
7. ?>
system示例:
1. 以下为引用的内容:
2.
3. $a = system("dir",$out);
4. print_r($a);
5. print_r($out);
6. ?>
3. php.ini,关掉安全模式safe_mode = off
首先,打开php.ini,关掉安全模式safe_mode = off,然后在看看 禁用函数列表 disable_functions = proc_open, popen, exec, system, shell_exec ,把exec去掉。
4. 参考
php中使用exec,system等函数调用系统命令.htm
Apache以及PHP的默认编码问题解决(详解)_php追逐_新浪博客.htm
版权声明:本文为博主原创文章,未经博主允许不得转载。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.
