PHP | shell_exec()

shell_exec() falls under the category of program execution functions in PHP which is used to execute command via shell and return the complete output as a string.

Example:

helloworld.py

print("Hello World!")

output.php

<?php
$output = shell_exec('python3 helloworld.py');
// Display the print output from helloworld.py
echo "<pre>$output</pre>";
?>