Hi, now I am confused.. very very very confused. I'm wondering if, in a method,
I should return an error object (somewhat similair to Pear_Error) or just return true or false. I looked to some PEAR files and I can't find the right pattern about when returning error object or true/false. Here's an exemple :
or :PHP Code:// }}}
// {{{ open()
/**
* Ouvre le fichier
*
* @param mode int Le mode du fichier
*
* @return bool true si le fichier a été ouvert, false sinon
*
* @access public
*/
function open($mode = FILE_OPEN_RW_CREATE)
{
$this->fp = @fopen($this->file, $mode);
return ($this->fp) ? true : false;
}
PHP Code:// }}}
// {{{ open()
/**
* Ouvre le fichier
*
* @param mode int Le mode du fichier
*
* @return mixed true si le fichier a été ouvert sinon un objet error
*
* @access public
*/
function open($mode = FILE_OPEN_RW_CREATE)
{
$this->fp = @fopen($this->file, $mode);
if (!$this->fp) {
return raiseError(sprintf('Unable to open file %s', $this->file));
}
return true;
}






.
. You are using a new type as an alternative to true/false/null.
Bookmarks