What return type use?

From: Date: Mon, 23 Feb 2004 16:33:16 +0000
Subject: What return type use?
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-25814@lists.php.net to get a copy of this message
suppose I have a function that return an array of something, for example, a list of users. if the function have to return that there's no users, what it should return: 1 - an empty array 2 - null 3 - false 4 - '' // empty string 5 - return an error 6 - return and raise an error I think the right answer will always be the option 1. Sine I'm expecting an array, I could do: foreach( functionReturn() as $key=>$value){ // code here } in others cases I have to check first if the return is really an array. if(is_array(functionReturn())){ foreach( functionReturn() as $key=>$value){ // code here } } What do you people think?

« previous php.pear.dev (#25814) next »