CodeIgniter -> Get current URL relative to base url

后端 未结 10 1187
情话喂你
情话喂你 2020-12-29 05:08

Tried URI::uri_string() but can\'t get it to work with the base_url.

URL: http://localhost/dropbox/derrek/shopredux/ahahaha/hihihi
Returns: dr

10条回答
  •  甜味超标
    2020-12-29 05:41

    In CI v3, you can try:

    function partial_uri($start = 0) {
        return join('/',array_slice(get_instance()->uri->segment_array(), $start));
    }
    

    This will drop the number of URL segments specified by the $start argument. If your URL is http://localhost/dropbox/derrek/shopredux/ahahaha/hihihi, then:

    partial_uri(3);  # returns "ahahaha/hihihi"
    

提交回复
热议问题