Atitit. execute cmd command line php

Source: Internet
Author: User
Atitit. execute cmd command line php Atitit. execute cmd command line php

1. execute the cmd command line to call the basis of the System Command 1

1.1. actual execution mode 1

1.2. Question 1 about space

1.3. Chinese path problems, program file read encoding settings 1

1.4. echo garbled 2

2. exec, system, and other functions call system commands 2

3. php. ini, disable safe mode safe_mode = off 3

4. Reference 3

1. execute the cmd command line and call the basis of the system command 1.1. actual execution mode

Processmonitor check. ..

PID: 115372, Command line: cmd.exe/c "D: \ workspace poor? \ AtiBrow \ exp_receipt.bat"

1.2. space issue

Double quotation marks

1.3. Chinese path problems, program file read encoding settings

In Php. ini, default_charset = "UTF-8" only sets the post and get encoding, and cannot set the read encoding of the Php file .. It is best to comment out this parameter so that it can be automatically determined based on the encoding of the file. otherwise, all the output php results are headers ('content-Type: text/html; charset = utf8

Author: old Wow's paw Attilax iron, EMAIL: 1466519819@qq.com

The reason is that php files are encoded using the system character set. windows XP in Chinese uses GB2312. each file header has a field to indicate the encoding method of the file.

When java source files are compiled with javac, the compiler uses system encoding by default to read the content in the source files. If the source file is not saved using system encoding, you can use the javac-encoding command to specify the specific encoding.

.. ..

1.4. echo garbled characters

Header ('content-Type: text/html; charset = gbk ');

2. exec, system, and other functions call system commands

Both are used to call the system shell command,

Differences:

Exec can return all the execution results to the $ output function (array). $ status indicates that the execution status 0 indicates success 1 indicates failure.

Systerm does not need to provide the $ output function. it directly returns the result. Similarly, $ return_var indicates that the execution status code 0 indicates that success 1 indicates failure.

Exec example:

1. the reference content is as follows:

2.

3. $ a = exec ("dir", $ out, $ status );

4. print_r ($ );

5. print_r ($ out );

6. print_r ($ status );

7.?>

System example:

1. the reference content is as follows:

2.

3. $ a = system ("dir", $ out );

4. print_r ($ );

5. print_r ($ out );

6.?>

3. php. ini: disable the security mode safe_mode = off.

First, open php. ini, turn off the safe mode safe_mode = off, and then look at the disabled function list disable_functions = proc_open, popen, exec, system, shell_exec to remove exec.

4. Reference

Use exec,systemwait in php to call the system command. htm

Apacheuses PHP to solve the problem. (for details, see _ php _sina blog .htm .)

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.