Computer >> Computer tutorials >  >> Programming >> PHP

pclose() function in PHP


The pclose() function closes a pipe opened by popen(). It returns the termination status of the process that was run. In case of an error -1 is returned.

Syntax

pclose(file_pointer)

Parameters

  • file_pointer − Specifies the pipe

Return

The pclose() function returns the termination status of the process that was run. In case of an error -1 is returned.

Example

<?php
   // opening a pipe
   $file_pointer = popen("/bin/ls", "r");
   pclose($file_pointer);
?>

Output

TRUE

Let us see another example.

Example

<?php
   // opening a pipe
   $file_pointer = popen("/executable/setup.exe", "r");
   pclose($file_pointer);
?>

Output

TRUE