- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
popen() function in PHP
The popen() function opens a pipe. It can be used with fgets(), fgetss(), and fwrite(). The file pointer initiated by the popen() function must be closed with pclose().
Syntax
popen(command, mode)
Parameters
command − Set the command to be executed
mode − Set the mode, such as “r”, “w”, etc.
Return
The popen() function returns TRUE on success. It returns FALSE if an error occurs.
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/installer.exe", "r"); pclose($file_pointer); ?>
Output
TRUE
Advertisements