codeigniter segment method codeigniter segment method codeigniter codeigniter

codeigniter segment method


Are you doing this in your view?

I dont know if $this->uri->segment will work inside views, never needed it myself.

Instead grab the URI inside your controller and pass it back to the view.

$this->load->view('some view', array(    'link'    => $this->uri->segment(6)));

-

<a href="<?php echo $link;?>">link</a>

Although I dont really understand why you would want to do that.


Its not url but uri

$this->uri->segment(6);

and i think you are missing = operator in the anchor

<a href="<?=$this->uri->segment(6)?>">MyLink</a>


From the resulting URL that you posted, it looks like you might be missing a forward slash.

<a href="/<?php echo $this->uri->segment(6); ?>">link text</a>

This would force the URL to forward to the root of your site, rather than to that location inside the current folder that the browser thinks it is in.