Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

johndoee's avatar

how run python command in php

i want to run python command in php. example

freqtrade backtesting --strategy AwesomeStrategy --dry-run-wallet 1000

how can run. i know python file running as follow

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

how can add command line in escapshellcmd() with path to python file.

0 likes
2 replies
johndoee's avatar

@Tray2

$path = 'path to. py file';

$files = shell_exec('ls '.escapeshellarg($path));
// Executes `ls 'path; rm -rf /'`;

is it correct?

Please or to participate in this conversation.