![]() |
question regarding default view - 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: question regarding default view (/showthread.php?tid=4111) |
question regarding default view - El Forum - 11-07-2007 [eluser]Unknown[/eluser] Hi, I am writing an application that has urls like: http://domain.com/profiles/view/3/ This would view the profile with id = 3. I have this working. Here's a snippet of the controller: (yeah, it's dirt simple) Code: function view($id) When I load : http://domain.com/profiles/view/, I get an error, because id is missing. How do I set the behavior when someone does not include an id? Thanks. question regarding default view - El Forum - 11-07-2007 [eluser]xwero[/eluser] Code: function view() question regarding default view - El Forum - 11-07-2007 [eluser]gtech[/eluser] you can also default id to NULL Code: function blog_view($id=NULL) be careful VIEW is a reserved word in php4 I read a post where someone had a problem with naming the functions view as it worked on php5 their locahost but not php4 where there server was hosted. question regarding default view - El Forum - 11-07-2007 [eluser]BravoAlpha[/eluser] I've been using something like this: Code: function view( $id=FALSE ) question regarding default view - El Forum - 11-07-2007 [eluser]Unknown[/eluser] excellent, thanks for the suggestions and for not laughing at my question! ![]() |