• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[DONE] Passing arguments to controller.

#1
[eluser]Unknown[/eluser]
Maybe this is a very basic question but i can´t find information for this.

How i show a 404 error when i have done a controller that receive arguments but if you dont send arguments, how to show the 404?

example

www.myexample.com/user/58 -> argument 58

www.myexample.com/user -> no argument..


Code:
funcion User($id)
{
if (isset($id)){
//bla bla search the info for the id
} else {
show_404();
}


i want to show_404() when there are no arguments but codeigniter says:

Argument is missing...


What i can do?? Excuse me, maybe this is a very very basic question, i dont found nothing about this in the guide..


Really thanks codeigniter community!!


Sorry if my english is not good.





/////////////////////////////////////


EDIT:

sorry my own error.


This form for correct this " stupid " mistake is :

when declaring function:

Code:
function User($user = ''){


}


Writting '' prevent that.


Excuse me again. Thanks.




Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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