You can use the php exec() function to execute a command line program.
You can read about it here:
I have used exec() to invoke the python interpreter, which then runs a python script that calculates an interest rate for a loan.
The value from the python script is returned to php and stored in a variable.
An example of the PHP exec() function used in PHP code:
$var = exec("python Newton.py $this->N $this->PV $this->PMT $this->FV $this->K 2>&1");
Here are some other related php functions of interest:
- eval() interprets as php code
- preg_replace() with /e modifier interprets as php code
- this is superceded, now use: preg_replace_callback()
- exec() runs execs and scripts
- passthru() runs a command returns output to browser
- backticks (like it works in a bash script) execs command
- system() like passthru without binary data
- popen() exec command and connects pipes to file descriptor
- fopen() opens with file handle
- readfile() opens and writes to browser
- file() reads file to an array
A very well written book that covers just about everything is: PHP 5 Power Programming, Prentice Hall, by Gutmans, Bakken, and Rethans.
I use the chm format of the php manual for detailed references: