CodeIgniter Forums
[DONE] Passing arguments to controller. - 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: [DONE] Passing arguments to controller. (/showthread.php?tid=48117)



[DONE] Passing arguments to controller. - El Forum - 01-05-2012

[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.