PHP Pclose () function

PHP

Syntax:
pclose(pipe)
Parameters used: The pclose() function in PHP only takes one parameter.
  • pipe:This is a required parameter and specifies the pipe opened by the popen() function.
Returned value:
Returns the exit status of the running process, or -1 in case of an error.Errors and exceptions:
  • To get the actual exit status , use the pcntl_wexitstatus()function.
  • pclose() returns 0 on each platform if popen() cannot execute the specified command.
  • Examples :
    Input: $my_file = popen ("/ bin / ls "," r "); pclose ($my_file); Output: 1 Input: $my_file = popen ('/ executable / gfg.exe',' r'); echo "' my_file'; ". get_class ($my_file). ""; $file_read = fread ($my_file, 4192); echo $file_read; pclose ($my_file); Output: 1 
    The programs below illustrate the pclose() function.Program 1
    // open the pipe $my_file = popen ( "/ bin / ls" , "r" );  
    // close my_file pclose ( $my_file ); ?>
    Output:
    1 
    Program 2 // open the pipe $my_file = popen ( '/ executable / gfg.exe' , ' r' );  
    // return the class name of the object using get_class() echo "' $my_file'; " . get_class ( $my_file ). "" ;  
    // read the file using fread() $filereader = fread ( $my_file , 4192); echo $filereader ;  
    // close the pipe pclose ( $my_file ); ?>
    Output:
    1 
    Link:
    http: / /php.net/manual/en/function.pclose.php