I'm using codeigniter for my projects and I would like to pass an id of 0 into the URL:
/resource/method/id
which translates into
/resource/method/0
the problem is that CodeIgniter ignores the 0 and responds to
/resource/method
Any workaround for this?
The reason why codeigniter, rather PHP is ignoring the id of 0 is because of PHP's type juggling.
0, "" (empty string) and false are all the same to PHP
When getting the URL segment, if codeigniter doesn't see the parameters it returns false. Although this is probably why you aren't getting the value. I've never seen the framework ignore the id.
Remember that:
(false == 0)
is true
while (false === 0)
is false
The first example checks if both values are equal, while the second checks if both are equal and the same type