Running a Python script on a PHP server

前端 未结 1 1750
死守一世寂寞
死守一世寂寞 2021-01-18 13:54

I am running a nginx web server, along with PHP-CGI.

I would like to know if it is possible to execute a Python script inside PHP pages, allowing both languages to b

相关标签:
1条回答
  • 2021-01-18 14:36

    exec will return the output of the shell command, but you still need to echo that to the page. The following code should work for you

    <body>
    
        <p>Hello! Here is a message: <?php echo exec('python hello.py'); ?></p>
    
    </body>
    
    0 讨论(0)
提交回复
热议问题