Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 30th, 2005, 1:07 PM   #1
ktsirig
Programmer
 
Join Date: Oct 2005
Posts: 54
Rep Power: 4 ktsirig is on a distinguished road
return_values PHP

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?
ktsirig is offline   Reply With Quote
Old Oct 30th, 2005, 1:13 PM   #2
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
It means that the program executed exited with a status of EXIT_FAILURE (1) and not EXIT_SUCCESS (0) and an error occurred. Generally anything above 0 means the program failed...
__________________

tempest is offline   Reply With Quote
Old Oct 30th, 2005, 2:03 PM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
It is, of course, purely convention. I can write a program that performs perfectly, and return the value 7,356. Nevertheless, I always return a 0 (EXIT_SUCCESS) for success and almost always 1 (EXIT_FAILURE) for anything else. While Tempest is absolutely correct, it isn't something one can bank on. I see jillions of things that return nothing. The executive usually replaces that nothing with something, but you can't know what it is, always. Check the documentation for the application, but be aware that someone who isn't doing it conventionally will probably not even address the question.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Oct 30th, 2005, 3:11 PM   #4
ktsirig
Programmer
 
Join Date: Oct 2005
Posts: 54
Rep Power: 4 ktsirig is on a distinguished road
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)..
ktsirig is offline   Reply With Quote
Old Oct 30th, 2005, 4:14 PM   #5
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
You are perfectly clear to us, but maybe we haven't been to you.

In a restatement of what DaWei said: The return value is not something that PHP knows the meaning of, it is set by the program you've executed at the end of processing... Please refer to the documentation for whatever program you are calling to determine what 0 (commonly EXIT_SUCCESS meaning a successful exit of the program) and 1 (commonly EXIT_FAILURE meaning a successful exit of the program) mean in terms of that particular 'program'...
__________________

tempest is offline   Reply With Quote
Old Oct 30th, 2005, 4:15 PM   #6
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
damn... that means all my programs are written wrong I always use 1 for success, 0 for failure.. seems most logical in my eyes, since 1 is often equal to true, and 0 to false.
Polyphemus_ is offline   Reply With Quote
Old Oct 30th, 2005, 4:18 PM   #7
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Quote:
damn... that means all my programs are written wrong I always use 1 for success, 0 for failure.. seems most logical in my eyes, since 1 is often equal to true, and 0 to false.
See what I mean? Regarding true/false, consider the following:

MY PROGRAM SCREWED UP.

One might reason that there is often one way for something to succeed and lebenty-jillion ways for it to fail. There's only one "zero". How are YOU going to allocate your indicative numbers?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:28 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC