0

This is the the php script i have written inside a html page

<?php
    echo "print php";
    $cs='python script.py';
    exec($cs,$out,$status);
    foreach($out as $value){
    echo "<div><p style=\"color:red;\">$value</p></div>";
    }
    ?>

Browser displays no output Where am i going wrong? Could someone please guide me on how to iterate through the output array am fetching? My python script gives few lines of output which is much like a text file. Thanxxx in advance for the help!!!

PooSac
  • 3
  • 2

1 Answers1

1

That's invalid for syntax, you're needing a foreach

foreach ($out as $value){
Jeff Puckett
  • 37,464
  • 17
  • 118
  • 167
  • Oh yeah thanks!! i changed it to foreach but not able to display the output on browser. can someone please help me with that? – PooSac Jun 22 '16 at 12:24
  • That should work if you've got exec enabled and the path to the script is correct. Check the value of `$status` and ensure you've got robust error reporting enabled. – Jeff Puckett Jun 22 '16 at 12:34
  • This is helpful for catching errors http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php – Jeff Puckett Jun 22 '16 at 12:35