-
Executer du Python avec PHP
<?php $command = escapeshellcmd('/usr/custom/creativpy.py'); $output = shell_exec($command); echo $output; ?>
NOTE 1 : Ne pas oublier de mettre l’interpréteur au début du fichier python :
#!/usr/bin/env python
NOTE 2 : le fichier python doit être exécutable :
chmod +x creativpi.py
Source PHP.net : http://php.net/manual/fr/function.exec.php
-
<?php $command = escapeshellcmd('python3 /usr/custom/test.py'); $output = shell_exec($command); echo $output; ?>
So,
$output = shell_exec("python qwerty.py"); var_dump($output);
-