pclose()
closes a pipe opened by the popen()
function. The file pointer initiated by the popen()
function must be closed with pclose()
.
pclose(resource $handle): int
handle
: The file pointer returned by the call to the popen()
function.pclose()
returns the termination status of the process that was run. is returned in case of an error.
The following code demonstrates the use of pclose()
. Here, the termination status returned from the call to pclose()
is stored in $exit_status
and printed out to the standard output.
<?php$handle = popen('/bin/ls', 'r');$read = fread($handle, 2048);$exit_status = pclose($handle);print_r("Exit Status: $exit_status\n");?>