Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codeigniter display warning error if argument in URL not provided

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.

like image 865
netrox Avatar asked Jun 03 '26 04:06

netrox


1 Answers

just learned that the solution is simple:

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

}
like image 68
netrox Avatar answered Jun 06 '26 06:06

netrox



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!