2016-06-16 42 views

回答

2

可以實現它通過使用$_SERVER

$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; 

這將返回實際路徑即http://www.urlabc.com/home.json

,並通過使用pathinfo你得到延長url爲

echo $ext = pathinfo($actual_link, PATHINFO_EXTENSION); 

if($ext=="json") 
{ 
    // json code 
} 

if($ext=="xml") 
{ 
    // xml code 
} 
0
I think you should use pass "json" as query parameter 
e.g.[http://www.example.com?type=json] 

也使用Codeigniter Rest服務器Click here