get Extension of requested file

Hi everyone,

I’d like to retrieve the file extension of the requested url (empty, .html, .xml, …) in order to show an xml response instead of a html response if that is requested.

Is there a way to do this?

I checked CRequest but it doesn’t seem to have that.

Any pointers?

You need to do this by yourself:




$pathinfo=Yii::app()->request->pathInfo;

if(($pos=strrpos($pathinfo,'.'))!==false)

   $extension=substr($pathinfo,$pos+1);



thanks,

I assume the best way would be to also add a filter which would change the default layout? and would change the viewpath to something like views/controller/xml/ ?