In PHP, popen() runs a shell command and opens a pipe to it. You can then read the output of the command or send data to it, just like with a file.
Use mode r to read what the command prints, or mode w to write data into the command. Always close the pipe with pclose() when you are done.
Syntax
Call popen() with the values you need. Start with this line.
PHP
$handle = popen('echo CodeToFun', 'r');
Call
What it does
popen('echo CodeToFun', 'r')
Runs the command and lets PHP read its output.
popen('sort', 'w')
Starts the sort command and lets PHP send lines into it.
popen('ls -l', 'r')
Reads a folder listing on Linux or macOS.
A pipe works in one direction only, so use r or w, not both. If you need to both write and read, use proc_open(). Some hosts turn off popen() for security, so check function_exists('popen') if your code must run everywhere.