Atitit. Run cmd command line PHP

Source: Internet
Author: User
Tags safe mode

Atitit. Run cmd command Line PHP

1. Run the cmd command line and invoke the base 1 of the system command

1.1. Actual operating Mode 1

1.2. Questions about Spaces 1

1.3. The problem of Chinese path. program file read encoding settings 1

1.4. Echo Garbled 2

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

3. PHP.ini. Switch off Safe mode Safe_mode = off 3

4. References 3

1. Runningcmdcommand line, the basis for invoking system commands1.1. Actual operating mode

Processmonitor check. Get..

pid:115372, Command line:cmd.exe/c "D:\workspace characters \atibrow\exp_receipt.bat"

1.2. Questions about Spaces

Two-pin solution

1.3. Chinese path problem, program file read encoding settings

The default_charset = "Utf-8" in php.ini is simply the code that sets the post,get , Cannot set read encoding for PHP file:

It is better to stare at this number, let him according to the encoding of the file itself to infer, otherwise the output PHP results are header (' Content-type:text/html;charset=utf8

Author:: Old Wow's paw attilax Ayron, email:[email protected]

Reprint please indicate source: Http://blog.csdn.net/attilax

The reason is PHP The file itself is encoded using the system character set, the Chinese Windows XP It's all used GB2312 . Each file header has a field that indicates how the file is encoded.

When compiling a Java source file with Javac, the compiler reads the contents of the source file by default with the system encoding.

Assuming that the source file is not saved with system encoding, you can specify a detailed encoding with the command javac-encoding

Lymphatic, can only not a PHP file encoding set to GBK.

Just OK.

1.4. Echo garbled

Header (' CONTENT-TYPE:TEXT/HTML;CHARSET=GBK ');

2. Exec,systemsuch as function call System command

These two are all used to invoke the system Shell command,

Different points :

  exec The ability to return all running results to the $output in the function ( array ), $status is the state of the run 0 for Success 1 to fail

  systerm no need to provide $output function, he is directly returning the result. Same $return _var is running status code 0 for success 1 for failure

  exec Demo Sample :

1. The following is the referenced content :

2. <?

Php

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

4. Print_r ($a);

5. Print_r ($out);

6. Print_r ($status);

7.?>

  system Demo Sample :

1. The following is the referenced content :

2. <?

Php

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

4. Print_r ($a);

5. Print_r ($out);

6.?>

3. php.ini, turn off safe mode.Safe_mode = Off

First, open the php.ini. Turn off Safe Mode Safe_mode = off, then look at the list of disabled functions disable_functions = Proc_open, Popen, exec, System, shell_exec, remove exec.

4. References

PHP uses functions such as Exec,system to call system commands . htm

Apache and PHP default encoding problem resolution (specific explanation)_php Chase _ Sina blog . HTM

Atitit. Run cmd command line PHP

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.