Page 1 of 1

Most efficent way to call to a program

Posted: Fri Feb 22, 2013 8:39 pm
by twinedev
I've never delt with this too much, know how to accomplish it, but want to know best method:

What is the best method to pass some values to a compiled program (c++) and retrieve its results in PHP?

Specifics are a Lamp environment (CentOS), running with cPanel. I have a client who has a "super secret calculation", and they want it so if someone hacked the site, unlike a PHP script, they can't just view the PHP code to see how it calculates this (yeah, ignoring the idea of decompilers for this discussion)

Thanks for advice on it.

-Greg

Re: Most efficent way to call to a program

Posted: Fri Feb 22, 2013 8:43 pm
by requinix
My vote goes to the proc functions, proc_open and proc_close being the most useful. Gives you a ridiculous amount of control over how to execute a command.

Re: Most efficent way to call to a program

Posted: Fri Feb 22, 2013 11:08 pm
by Christopher
exec() is probably the easiest. It allows you to get the output of the program in a var.

Re: Most efficent way to call to a program

Posted: Sun Feb 24, 2013 2:30 am
by twinedev
Thanks, I knew of exec, just wasn't sure which was most efficient. About the only thing I have really used before was system to call ImagMagik (convert) for image resizing.

Re: Most efficent way to call to a program

Posted: Sun Feb 24, 2013 9:53 am
by Christopher
I really don't know "which was most efficient." My guess is that there is very little call overhead difference between proc_open(), exec() and the other system functions.