ฟังก์ชัน pclose() ใช้ ปิด pipe ที่เปิดด้วย popen() ส่งคืนสถานะการสิ้นสุดของกระบวนการ (termination status) ส่งคืน -1 หากเกิดข้อผิดพลาด
ไวยากรณ์ (Syntax)
pclose(file_pointer)
พารามิเตอร์ (Parameters)
file_pointer − ไฟล์พอยน์เตอร์จาก popen()
ค่าที่ส่งคืน (Return Value)
ส่งคืนสถานะการสิ้นสุดของกระบวนการ (integer) ส่งคืน -1 เมื่อเกิดข้อผิดพลาด
ตัวอย่างการใช้งาน
ตัวอย่างที่ 1: ปิด pipe หลังรัน ls
<?php
$file_pointer = popen("/bin/ls", "r");
pclose($file_pointer);
?>
ผลลัพธ์
TRUE
ตัวอย่างที่ 2: ปิด pipe หลังรัน setup.exe
<?php
$file_pointer = popen("/executable/setup.exe", "r");
pclose($file_pointer);
?>
ผลลัพธ์
TRUE