Here is a piece of code in my index.php
<?php
/*cmd is a program wittern by another people that I do not know much*/
$cmd="absolutePath/cmd";
$ret=0;
system($cmd,$ret);
?>
<p id="return"><?php echo $ret?></p>
If I just exec the program in command line like this: $ absolutePath/cmd
and then echo $?
I get 0, which is correct
if I exec the index.php in command line like this: php -f index.php
I get <p id="return">0</p>
in the output, which is correct.
However if I open the web page in browser(both chrome and IE),
I get <p id='return'>134</p>
and the error message:
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid Aborted
the problem looks same with this one I found on stackoverflow: Error executing praat from PHP: terminate called after throwing an instance of 'MelderError' Aborted while the exception throwed is different.