PHP 7 Script to Run Python Script in Browser Full Project For Beginners

  • Post author:
  • Post category:PHP
  • Post comments:0 Comments

 

 

index.php

 

 

<?php
   $command_exec = escapeshellcmd('path-to-.py-file');
   $str_output = shell_exec($command_exec);
   echo $str_output;
?>

 

 

Where you need to provide the path to the python file and then we are using the shell_exec() function in php to execute python code inside the server.

 

Leave a Reply