Most efficent way to call to a program

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Most efficent way to call to a program

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Most efficent way to call to a program

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Most efficent way to call to a program

Post by Christopher »

exec() is probably the easiest. It allows you to get the output of the program in a var.
(#10850)
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Most efficent way to call to a program

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Most efficent way to call to a program

Post 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.
(#10850)
Post Reply