Running Python script in PHP: capture all outputs
<p>I have a <code>Python</code> program that has multiple <code>print</code> statements in it. When I execute the program from <code>PHP</code>, the output displayed is just the value printed by the last <code>print</code> statement. Is there a way to capture values printed by all the <code>print</code> statements in the <code>Python</code> script?</p>

<p><code>PHP</code> code:</p>

<pre><code>&lt;?php
ini_set('display_errors', 1);
$output = exec("python script.py");
echo $output;
?&gt;
</code></pre>