Pipe pipeline app _ PHP Tutorial

Source: Internet
Author: User
Pipe pipeline application. A friend of linux must know the pipe (pipeline) function provided by shell. maybe you do not know his full name yet. you have never used the following command: catINSTALL | more commands of this type. a linux user must know the pipe (pipeline) function provided by shell. maybe you do not know its full name, you have never used such a command:
Cat INSTALL | more
This type of command is used by pipeline technology, which is different from redirection.
The popen function is provided in PHP to open a pipeline:
Int popen (string command, string mode );
Popen () open a pipeline, that is, open the processing file pointer. After opening an MPs queue, a file pointer is returned. the subsequent usage is the same as that for reading and writing common files. Let's take a look at the following:
$ Fp = popen ("/bin/ls-l-FN/ect", "r ");

While (! Feof ($ fp ))
Ehco fgets ($ fp, 4096 )."
";

Pclose ($ fp );
?>
Try the output.
Pipeline is widely used. for example, we can open a sendmail pipeline to send emails. Pipelines are easier to understand than sockets. The socket must be used to understand how to interwork with sendmail, while the pipeline action can be used to pre-process common files. Take a look at the following program and you will understand that this program will send an email to The yqqfgq@china.com:
$ Fp = popen ("/usr/sbin/sendmail yqqfgq@china.com", "w ");

$ Message = "Hi! Yes, I am yqqfgq! :) N ";

Fputs ($ fp, "Subject: $ subjectn ");
Fputs ($ fp, "From: yqqfgqn ");
Fputs ($ fp, "Reply-to: yqqfgq@china.com ");
Fputs ($ fp, $ message );
Fputs ($ fp ,".");

Pclose ($ fp );

?>
Easy to use! That's all. If you have any comments, contact me. Yqqfgq@china.com

Pipeline function, maybe you do not know its full name, you have never used this command: cat INSTALL | more this type of command...

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.