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

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 24-Jun-2020

78 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements