You want to pass input to an external program run from inside a PHP script. You might, for example, use a database that requires you to run an external program to index text and want to pass text to that program.
Open a pipe to the program with popen( ), write to the pipe with fputs( ) or fwrite( ), and then close the pipe with pclose( ) , as in Example 23-42.
Passing input to a program
Example 23-43 uses popen( ) to call the nsupdate command, which submits Dynamic DNS Update requests to nameservers.
Using popen( ) with nsupdate
In Example 23-43, two commands are sent to nsupdate via popen( ). The first deletes the test.example.com A record, and the second adds a new A record for test.example.com with the address 192.168.1.1.
23.17.4. See Also
Documentation on popen( ) at http://www.php.net/popen and pclose( ) at http://www.php.net/pclose; Dynamic DNS is described in RFC 2136 at http://www.faqs.org/rfcs/rfc2136.html.