CodeIgniter Forums
Why This Particular Function Structure? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Why This Particular Function Structure? (/showthread.php?tid=59434)



Why This Particular Function Structure? - El Forum - 10-04-2013

[eluser]nc_wolf[/eluser]
Can someone help me understand the following code snippet please? My question is, what is the purpose of passing in a value of false in this function and then immediatley setting it back to true when the function is called. Here is the code (this is the tank_auth authentication library FYI). It just seems like there is no reason to pass in the false at all. It just gets set right back to true. Or, am I missing something about how a function works when its argument is set to a value in the function declaration itself?


Function Call:
Code:
$this->tank_auth->is_logged_in(FALSE)

Function:

Code:
function is_logged_in($activated = TRUE)
{
  return $this->ci->session->userdata('status') === ($activated ? STATUS_ACTIVATED :     STATUS_NOT_ACTIVATED);
}

Many thanks!

nc_wolf