Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Depending on what you are doing, <a href="http://php.net/manual/en/function.system.php" rel="noreferrer">system()</a> or <a href="http://php.net/manual/en/function.popen.php" rel="noreferrer">popen()</a> may be perfect. Use system() if the Python script has no output, or if you want the Python script's output to go directly to the browser. Use popen() if you want to write data to the Python script's standard input, or read data from the Python script's standard output in php. popen() will only let you read or write, but not both. If you want both, check out <a href="http://us.php.net/manual/en/function.proc-open.php" rel="noreferrer">proc_open()</a>, but with two way communication between programs you need to be careful to avoid deadlocks, where each program is waiting for the other to do something.</p> <p>If you want to pass user supplied data to the Python script, then the big thing to be careful about is command injection. If you aren't careful, your user could send you data like "; evilcommand ;" and make your program execute arbitrary commands against your will.</p> <p><a href="http://www.php.net/manual/en/function.escapeshellarg.php" rel="noreferrer">escapeshellarg()</a> and <a href="http://www.php.net/manual/en/function.escapeshellcmd.php" rel="noreferrer">escapeshellcmd()</a> can help with this, but personally I like to remove everything that isn't a known good character, using something like</p> <pre><code>preg_replace('/[^a-zA-Z0-9]/', '', $str) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload