Welcome Guest, Not a member yet? Register   Sign In
[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.






Theme © iAndrew 2016 - Forum software by © MyBB