對於我的Rest WebService,我需要一些變體來放置城市或區域或其他內容。所以我的URI應該是這樣的:帶問號的URI段
/rest/rating/locations?city=London
現在,我使用下面的函數來獲得最後的URI段:
$segcount = $this->uri->total_segments();
$lastseg = $this->uri->segment($segcount);
的問題是在這裏從問號寄託都被板缺! 它會保存變量就是:
我試過配置位置以下的config.php文件:
$config['uri_protocol'] = 'PATH_INFO';
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-?';
$config['enable_query_strings'] = TRUE;
是否有任何其他的可能性,以節省問號整段?
我很困惑,'$ this-> uri-> total_segments()'只返回**#**段。你不想要這個:'$ this-> uri-> segment_array()' –
@tim:他的方法獲取* last * URL段(無論什麼原因)。 –
是的,我需要最後一段,之後我將使用'$ city = substr($ lastseg,strlen(「locations?city =」))'來獲得城市的字符串 – milepile