Having found out that 3rd URL segments can be passed directly to the a function’s parameter I did the following.
URL example:
Function in profile controller:
function user($user_id) //$user_id is 3rd URL segment
{
//get data for user with id = $user_id
}
Using $this->uri->segment(3) returns FALSE is no segment exists. With the function parameter I get
Missing argument 1
How can I return FALSE and not execute the function if the 3rd URL segment is missing? I’m looking for a simple solution without if statements, if possible.
What about default arguments: