• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Controller who detect the use of URI segments

#1
[eluser]Sein Kraft[/eluser]
Hi everybody!

I'm working in a user management system and I've a trouble x3

I have a function called "Activate" with a variable catch.

Code:
function Activate($key)
{
}

And the system has the possibility of detect the content of $key. If the variable have data jump to the model to activate the user. And If not show a view with a simple form who request the activation key an then call the model and activate.

Code:
function Activate($key)
{
   if ($key = '')
      {
         //form validation...
         $this->load->view('user_activate', $data);
      }
   else
      {
         //send $key to model...
         $this->load->model('model_user','', TRUE);
         $this->model_user->activate_user($key);
      }
}

But the system doesn't work properly. It show an error in the first line of the function because it expect a value with content, not a null value.

#2
[eluser]Pascal Kriete[/eluser]
PHP allows for parameter defaults. Easy as pie:
Code:
function Activate($key = '')

#3
[eluser]Sein Kraft[/eluser]
Ouch, it hurts x3

Thanks for the reply inparo


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.