Help with REQUEST_URI comparison

Hi guys, I have a very simple question that I just can’t seem to figure out. I have a piece of code shown below, the problem is this will not work if you change the way urlManager works. How do I make this work for either case of using or not using urlManager?

Reason for code: need to run specific code from a page based on the URI




if($_SERVER['REQUEST_URI'] == '/index.php/test')



Stepped away to let my brain relax and found my answer




if($_SERVER['REQUEST_URI'] == $this->createUrl('/test'))



If you want to test for a specific route, it would be safer to verify Yii::app()->controller->route. It contains the route of the current request. In view context this can be accessed with $this->route.