A friend of Linux must know the pipe (pipe) function provided by the shell, perhaps you do not know his full name, then you have not used such a command:
Cat INSTALL | More
This type of command usage is based on the technology of the pipeline, which is different from redirection (redirection).
PHP provides the Popen function to open a pipeline:
int Popen (string command,string mode);
Popen () opens a pipe, that is, opens the handle file pointer. When a pipeline is opened, a file pointer is returned, and the next usage is the same as reading the normal file. Let's look at the following:
$FP =popen ("/bin/ls-l-fn/ect", "R");
while (!feof ($FP))
Ehco fgets ($fp, 4096). "
";
Pclose ($FP);
?>
The result of the output you try it.
Pipelines are widely used, for example, we can open a SendMail pipeline to send e-mails. Using a pipe is easier to understand than a socket. Because the socket must know how to handle with the SendMail, while the pipeline action preprocessing ordinary files is no different. Take a look at the program below and you'll see that this app will send an email to yqqfgq@china.com:
$FP =popen ("/usr/sbin/sendmail yqqfgq@china.com", "w");
$message = "hi! is me, 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);
?>
It works! Oh, so much more. Please contact me if you have any comments on our brothers. Yqqfgq@china.com
http://www.bkjia.com/PHPjc/532084.html www.bkjia.com true http://www.bkjia.com/PHPjc/532084.html techarticle a friend of Linux must know the pipe (pipe) function provided by the shell, perhaps you do not know his full name, then you use no such command: Cat INSTALL | More This type of command ...