I want to call a C++ program from PHP with apache server on Fedora 12 linux.
testprog is put in the same directory of the test php program.
I see the output of exec('ls -lrt') but not exec("testprog").
Please help.
The following are my php and cpp test programs.

<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
<?php
echo exec('ls -lrt');
echo exec("testprog");
?>
 </body>
</html>

testprog.cpp

#include <iostream>
#include <algorithm>

int main() {
  int array[] = { 23, 5, -10, 0, 0, 321, 1, 2, 99, 30 };
  int elements = sizeof(array) / sizeof(array[0]); 
  std::sort(array, array + elements);
  for (int i = 0; i < elements; ++i) 
     std::cout << array[i] << ' ';
}

try:

echo exec("./testprog");

try:

echo exec("./testprog");

It works!
Thanks.
Why specifying the current path "." in the PATH environment is not good enough?
$ echo $PATH
/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/local/sbin:/usr/sbin:/sbin:.

Maybe the PHP exec() method doesn't search the BASH $PATH?
In general.the more specific you are about a path the better. Less assumptions to bite ya in the butt!

Please mark as solved.
Thanks

It works!
Thanks.
Why specifying the current path "." in the PATH environment is not good enough?
$ echo $PATH
/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/local/sbin:/usr/sbin:/sbin:.

Detection sometimes. $ Exec () function associated with.