I have noticed that most PHP-based libraries or frameworks have classes that don’t explicitly return the keywords TRUE and FALSE, instead:
if(condition)
{
$this->boolean_property = FALSE;
return $this->boolean_property
}
does this mean anything or is it just another “purist” move which does not present any advantage over the other approach?
here is another code from an authentication library:
protected $_logged_in = false;
public function is_logged_in()
{
if (isset($_SESSION['userdata'])
{
$this->_logged_in = true;
}
return $this->_logged_in;
}
The second example makes sense, probably the class is checking for the
$_logged_inproperty at a latter stage.The first one could be simplified to:
However it still seems stupid by itself, and a simple
return false;would be preferable.