1

How do I execute a Python file from PHP?

I have a Python parser in my project that will get video source from another site. I plan to do so by

  1. Writing in text file url (from PHP).
  2. Starting a Python script (from PHP).
  3. Python script will get that url from text file
  4. Finally Python script will write that video source in other text file
  5. PHP will read that file with source and will use that further.

At 2., how do I start the python script?

Vadim Melnikov
  • 100
  • 2
  • 7

1 Answers1

1

You can take a look at proc_open and shell_exec.

proc_open will allow you to run other code while waiting for the command to finish.

shell_exec will run the command and return the output after the command has finished.

As always, the php documentation has nice examples, I trust you'll find what you seek for.

bendem
  • 185
  • 2
  • 9