return values PHP

A

Anonymous

Guest
I have trouble understanding the meaning of the return_var in PHP.
I read that it is used in order to inform us if a PHP command has been executed.
I use system commands in PHP (like 'system', 'shell_exec' etc) and I can't find anywhere a list of the return_vars.
I mean that 0 is for 'OK, the command was executed'.
What does 1 stand for???
I execute a system command , I don't get any result, and if I ask PHP for the return_var, it says '1'.
Where could I find more info as to what return_var=1 means?
 
actually 0 and 1 are the int representation of boolean variables.
But what functions are you using, because often you will get a string output or an array output
It all depends on what parameters you are using.

in PHP you can do like this:

Code:
<?php
if(function())
{
   //Do if its excecuted OK
}
else
{
   //some problems
}
?>
or like this (note the ! before func
Code:
tion)
<?php
if(!function())
{
   //some problems
}
else
{
   //Do if its excecuted OK
}
?>
 
Hi, thanx for your time.
My problem really has to do with WHAT the return values mean.
My problem is that I call an external program through PHP, using system ('program', $return_value);

I wanted to know if there is any kind of documentation saying perhaps that 'if you have $return_value=1, then it means that you have ... problem'.
I hope I am clear to you. i want to figure out WHY the program hasn't been called from PHP, so as to fix the problem if I can (if it has to do with permissions or whatever)..
 
okey.. the $return value is simply an output that your program made.. for instance if you will use something ile ping on windows machine: your $return_value will most probalby containa ping result.. all the output that the program makes.

to know if its called or not: try this:

Code:
<?php
if(!system('program', $return))
{
   echo("Program did not run, returned: ".$return);
}
else
{
   echo("Program did run and returned: ".$return);
}
?>
 
Back
Top