PHP system ()

Source: Internet
Author: User

PHP function system details:

Execute an external program and display the output data.

System Syntax: String System (string command, int [return_var]);

System return value: String

Function types: operating system and environment

 

System description

This function is like the system () function in C, used to execute commands and output results. If the return_var parameter exists, the status after command execution is filled in return_var. It is also worth noting that escapeshellcmd () can be used to process user input data and prevent users from cracking the system by means of tricks (). If PHP is executed in a modular manner, this function automatically updates the output buffer area of the Web server after each row is output. Passthru () can be used to return complete strings without passing through any other intermediate output interface ().

 

Command,. bat, etc.), can also execute cmd commands, Linux is more widely used, because the Linux system is based on command lines, such as basic ls, CP, RM, etc. For example, a bat file in Windows contains the following content:

@ Echo off
Echo clears the temporary IE File directory...
Del/f/S/Q "% USERPROFILE %/Local Settings/Temporary Internet Files /*.*"
Del/f/S/Q "% USERPROFILE %/Local Settings/temp /*.*"

ECHO is clearing the system temporary file *. tmp *. _ TMP *. log *. Chk *. Old. Please wait...
Del/f/S/Q % systemdrive %/*. tmp
Del/f/S/Q % systemdrive %/*. _ MP
Most REM. log files may be useful.
Rem del/f/S/Q % systemdrive %/*. Log
Del/f/S/Q % systemdrive %/*. GID
Del/f/S/Q % systemdrive %/*. Chk
Del/f/S/Q % systemdrive %/*. Old

Echo clears garbage bins, backup files, and pre-Cache scripts...
Del/f/S/Q % systemdrive %/recycled /*.*
Del/f/S/Q % WINDIR %/*. Bak
Del/f/S/Q % WINDIR %/prefetch /*.*
RD/S/Q % WINDIR %/temp & MD % WINDIR %/temp

Rem coke and recent history should be retained...
Rem del/f/Q % USERPROFILE %/cookies S /*.*
Rem del/f/Q % USERPROFILE %/recent /*.*

Echo clears useless system disk files...
% WINDIR %/system32/sfc.exe/purgecache

Echo optimized pre-read information...
% WINDIR %/system32/defrag.exe % systemdrive %-B

Echo system cleared!

Echo. & pause

The purpose of this file is to remove system garbage. You can execute it using the system function to complete cleaning. The Code is as follows:

<? PHP

System ('COMMAND. bat', $ callback );

Echo $ callback;

?>

The $ callback variable indicates the output information of the executed file.

With Linux commands, you can easily decompress the tar file online (must be a Linux system ):

<? PHP

System ('tar xvf filename.tar ', $ callback );

Echo $ callback;

?>

If the system permits this, you can use the system function for more work.

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.