Difference between revisions of "BeBot Standard Return Array"

From Bebot Wiki 2
Jump to navigationJump to search
(Created page with '====== BeBot Standard Return Array ====== Many BeBot functions return an array with a standard format. There is currently no policy that module developers follow this format when…')
 
(No difference)

Latest revision as of 22:43, 16 September 2020

BeBot Standard Return Array[edit]

Many BeBot functions return an array with a standard format. There is currently no policy that module developers follow this format when their function(s) return data.

Return Array Elements[edit]

There are three elements in a BeBot Standard Return Array: bool error, string errordesc, and mixed content.

$return = array('error' => FALSE, 'errordesc' => , 'content' => );

Example Usage[edit]

function return_parameter($parameter) {

   $return['error'] = FALSE;
   $return['errordesc'] = ;
   $return['content'];
   if (is_null($parameter))
   {
       $return['error'] = TRUE;
       $return['errordesc'] = 'parameter passed to function return_parameter is null.';
   }
   else
   {
       $return['content'] = $parameter;
   }

}

function calling_function($input) {

   $result = $this -> return_parameter($input);
   if ($result['error'])
   {
       return $result['errordesc'];
   }
   else
   {
       return $result['content'];
   }

}