On Mon, Jun 9, 2008 at 9:11 AM, R B <rbpphp@xxxxxxxxx> wrote: > Hi, > I have a C++ script containing the function hello(x, y, z) > > I want to access this C++ function from PHP, and output with PHP the return > information. > > How can i do this? The cheating, quickest, easiest way, would be to write the function into a portable C++ script, compile it to binary form, and pass `x`, `y`, and `z` as argv[]'s via PHP's exec() function, like so: <?php $ret = null; // In the exec() call below, note the quotes around special characters and spaces. exec('./cpp-binary argument1 argument2 "argument three?"',$ret,$err); if(count($ret) > 1) { foreach($ret as $r) { echo $r."<br />\n"; } } elseif(count($ret) == 1) { echo $ret[0]."<br />\n"; } else { echo "Nothing returned by exec()! Error Level: ".$err."<br />\n"; } ?> -- </Daniel P. Brown> Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php