[eluser]F. Albrecht[/eluser]
Hi all,
I'm just porting a procedural PHP project to CI and it rocks. The code is cleaner, compacter, better to read and will scale in the future...
At the moment I have one question about URI routing:
Code:
$route['(my_link)/?(:any)?/?'] = "my_controller/my_function/$1/$2";
In my_controller.php:
Code:
function my_function($foo, $bar = 'foo')
{
echo "bar = " . $bar;
}
The link
Code:
www.domainname.tld/index.php/my_link/12
generates
Quote:bar = 12
The link
Code:
www.domainname.tld/index.php/my_link
generates
Quote:bar =
but should generate
A vardump via
says
Quote:string(0) ""
What happens to my 'foo'? Anything wrong with my route/logic/code?
I guess that a possible workaround this
Code:
if ( !empty($this->uri->segment(2)) ) make foo else make bar
or this
Code:
if ( !empty($bar)) ) make foo else make bar
snippet is?
Thanks for reading!