Sounds like you're looking for output buffering:
ob_start();
system($command, $returnCode);
$output = ob_get_clean();
This should preserve all white-space characters at the end of each output line (exec as you wrote destroys these, so implode would not be an option).
Alternatively, you can open a process and aquire the pipes (standard output, STDOUT) and read the output out of these. But it's more complicated (but gives you more options). See proc_open.
Videos
try
exec("convert -version 2>&1", $out, $ret);
print_r($out);
it should tell you what's wrong
It looks like the -version flag is telling the convert software (looks like imagemagick) to respond with the major version number of that software. It looks like it is working correctly. You probably need to pass it the right flags to operate properly. I suggest reading the documentation to see what flags are required to convert PDFs.
return as the word itself says returns (gives back) something.
In this case either $var1 + $var2 or $var1 - $var2.
Variables inside of a function can't usually be accessed outside of it.
With return however you can get something from inside a function to use it oustide of it.
Keep in mind, that a return will end the execution of a function.
Return sets the function as a string, int, bool etc.
Without the key word return, the function is a blackhole.
In function Adding:
$totaal = $getal1 + $getal2;
return $totaal; // return returns $getal1+getal2
It can be shortened into:
return $getal1 + getal2;
When you are doing echo Adding($getal1, $getal2);
You are actually doing echo $getal1 + $getal2;
You might want to check if it's calling the right php executable on th Unix machine. On many UNIX systems you would need to call the php-cli executable insted of the php one for use on the command line. Another thing to check would be permissions. Maybe the user executing the script_b.php script doesn't have permissions to execute script_a?
__halt_compiler() is called somewhere , able to check that ?
Return codes can be a bit arbitrary. Basically though, any non-zero return value is an error. Here's a list of some common ones, but typically, unless you're working with a specific program, it's easier to just assume non-zero = some error was found, as opposed to trying to map a number of different programs to specific error codes.
Return code 127 means The specified procedure could not be found.
Assuming you are on Windows, Windows System Error Codes
The return value is dependent on the process/program that you ran with exec. For instance, if you ran grep:
The exit status is 0 if selected lines are found, and 1 if not found. If an error occurred the exit status is 2. (Note: POSIX error handling code should check for '2' or greater.)
rsync has about 20 different error exit codes, all painstakingly explained in the man page:
http://linux.die.net/man/1/rsync
so yes, it's program-dependant :)
Even if you're running PHP script, the exit value depends on your program itself. By default php scripts will exit with 0. If you use the exit function you can return different exit codes:
http://php.net/manual/en/function.exit.php
If you want to experimentally determine what your php program exits, call it on the command line:
php file.php
then do
echo $?
this will show you the exit value of your php script.
IMHO, before use exec() function better set output and return_var parameters and read return code execution by return_var. Don't rely on exec() return value.