pclose()

pclose() — Closes process file pointer.

Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

What it does

Closes a file pointer to a pipe opened by popen().

Signature

pclose(resource $handle): int

Parameters

ParameterTypeWhat it takes
$handleresourceThe file pointer must be valid, and must have been returned by a successful call to popen().

Return value

Returns the termination status of the process that was run. In case of an error then -1 is returned. Note: If PHP has been compiled with --enable-sigchild, the return value of this function is undefined. If PHP has been compiled with --enable-sigchild, the return value of this function is undefined.

Example

A runnable snippet:

$handle = popen('/bin/ls', 'r'); pclose($handle);

See also

popen()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page pclose() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.