Saturday, 4 October 2014

pclose in PHP

pclose — Closes process file pointer
Syntax:

int pclose ( resource $handle )
Closes a file pointer to a pipe opened by popen().

Parameters:

handle
The file pointer must be valid, and must have been returned by a successful call to popen().

Return values: Returns the termination status of the process that was run. In case of an error then -1 is returned.



Example #1 pclose() example

<?php
$handle = popen('/bin/ls', 'r');
pclose($handle);
?>


Note: Unix Only:
pclose() is internally implemented using the waitpid(3) system call. To obtain the real exit status code the pcntl_wexitstatus() function should be used.

0 comments:

Post a Comment