[Python] How to get data from Python over to PHP

Discussão em 'Python' iniciado por Stack, Abril 19, 2025.

  1. Stack

    Stack Membro Participativo

    What are the possible methods to do this?

    When I either open a page or click a button on my PHP website, it runs a python program that returns some data (maybe a string) back to PHP.

    It seems people keep saying to use exec or shell exec, but I tested this on WAMP, didn't work for me (perhaps I did something wrong).

    Is there a method I could do something like an API but not to access a database but to just run a program?


    I was able to get something using:

    exec('python get.py', $output);
    var_dump($output);


    using the above, I got this output:

    C:\wamp64\www\ai\get.php:10:
    array (size=0)
    empty


    My python code is just a print statement that says hello world. Do I need something for python side?

    Continue reading...

Compartilhe esta Página