Welcome Guest, Not a member yet? Register   Sign In
uri->segment(0) return FALSE in _remap function
#1

[eluser]Zandy[/eluser]
Hi!

I'm trying to extract the parameters in the _remap function, but the function uri->segment(0) I always returns false.

Code:
<?php
class Prueba extends Controller
{
    function __construct(){ parent::Controller(); }
    
    function pru( $some ) { }
    
    function _remap( $method )
    {
        echo $this->uri->segment(0);
    }
}
?>

the url in browser is
http://localhost:8080/test/index.php/pru...eParameter


should return "someParameter" ??

greetings
#2

[eluser]llbbl[/eluser]
"someParameter" would be the 3rd segment of the URI.

http://ellislab.com/codeigniter/user-gui...s/uri.html

http://example.com/index.php/news/local/...rime_is_up

The segment numbers would be this:

1. news
2. local
3. metro
4. crime_is_up

By default the function returns FALSE (boolean) if the segment does not exist. There is an optional second parameter that permits you to set your own default value if the segment is missing. For example, this would tell the function to return the number zero in the event of failure:

$product_id = $this->uri->segment(3, 0);
#3

[eluser]Zandy[/eluser]
I've tried to 0 to 5....

and nothing,
#4

[eluser]llbbl[/eluser]
it's (3,0) but (3) should work also assuming your url is formatted like above

/prueba/pru/someParameter
#5

[eluser]sophistry[/eluser]
do a fresh CI install and try your _remap code again. something is wrong with your CI install if it doesn't have uri segments in the uri object.




Theme © iAndrew 2016 - Forum software by © MyBB