[PHP] Returning error code from a function
I am wondering if someone could shed some light on this aspect of PHP It might be something obvious, but I am not able to figure it out I have a function that returns a dynamically generated HTML string However, I need a way to let the caller know if that function has failed One way I thought of, is to have an empty return: return; hoping that I could check for isset() However, isset reports 1 (In the C world, I could easily check for NULL) Is there a way in PHP to return a failure flag back to the caller? (Of course, I could use an argument as a success flag But, I am wondering if there is a way to do it in the return variable) Thank you in advance __ Do You Yahoo!? Yahoo! Sports - sign up for Fantasy Baseball http://sportsyahoocom -- PHP General Mailing List (http://wwwphpnet/) To unsubscribe, visit: http://wwwphpnet/unsubphp
Re: [PHP] Returning error code from a function
Anas, I am wondering if someone could shed some light on this aspect of PHP. It might be something obvious, but I am not able to figure it out. I have a function that returns a dynamically generated HTML string. However, I need a way to let the caller know if that function has failed. One way I thought of, is to have an empty return: return; hoping that I could check for isset(). However, isset reports 1. (In the C world, I could easily check for NULL.) Is there a way in PHP to return a failure flag back to the caller? (Of course, I could use an argument as a success flag. But, I am wondering if there is a way to do it in the return variable.) You could try: return FALSE; Remember that an IF condition can use == for 'same value' or === for 'same value and same type'. NB I do not recommend/condone the use of a single variable/return value to represent multiple data types, but if you're going to do it, this is about the best mechanism. Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Returning error code from a function
On Sat, 2 Mar 2002, Anas Mughal wrote: I am wondering if someone could shed some light on this aspect of PHP It might be something obvious, but I am not able to figure it out I have a function that returns a dynamically generated HTML string However, I need a way to let the caller know if that function has failed One way I thought of, is to have an empty return: return; hoping that I could check for isset() However, isset reports 1 (In the C world, I could easily check for NULL) Is there a way in PHP to return a failure flag back to the caller? (Of course, I could use an argument as a success flag But, I am wondering if there is a way to do it in the return variable) i would use something like if(strlen($get_html())0) //do something else // do nothing -- --- Greg Donald - http://destineycom/ http://phpratedcom/ | http://phplinksorg/ | http://phptopsitescom/ --- -- PHP General Mailing List (http://wwwphpnet/) To unsubscribe, visit: http://wwwphpnet/unsubphp