views:

22

answers:

2

If I don't provide the value in the URL for Codeigniter, it'll display a PHP Error was encountered saying it's missing argument for a function call. I do NOT want it displayed at all. If there's no argument in the URL, it should just reroute to its index function. How do I prevent that from happening?

For example, www.example.com/profile/id/45

anyone would guess and enter like this "www.example.com/profile/id"

that would generate the error. How do I prevent that? I tried, "if (!isset($id))" but it generated error before it reached to that condition.

A: 

just learned that the solution is simple:

function id($id=NULL)
{
 if ($id===NULL)
 {
  redirect....
 }

}
netrox
A: 

you can also use:

$this->uri->segment(2); // gets 'id'
$this->uri->segment(3); // gets '45'

then do a redirect, check out:

http://codeigniter.com/user_guide/helpers/url_helper.html
Maikel