0

I have a puppeteer progam that I execute by entering c:\myProgram>node index.js in the command prompt. Instead of entering this in the command prompt, I would like to have the command run from my PHP program.
Something like this pseudo-code:

When button is clicked,
   call function

Where the function will enter the command in the command prompt for me. I am using Visual Studio Code and the integrated terminal could be used instead (I think).

What code could replace call fucntion in my example?

hardkoded
  • 18,915
  • 3
  • 52
  • 64
JULIE_0420
  • 43
  • 4

1 Answers1

0

You need to use exec(), system() or passthru() functions.

There's another SO post with details on all 3. Personally I prefer passthru()

exec() vs system() vs passthru()

And a slightly more advance usage of passthru() here, depends on what you need you should be covered with those two links.

passthru() vs shell_exec()

Dharman
  • 30,962
  • 25
  • 85
  • 135
Oliver M Grech
  • 3,071
  • 1
  • 21
  • 36