Error when parsing URL, please...

I get a problem when I using


parseUrl

function.

I write this code;




echo '<pre>';

var_dump(Yii::app()->getUrlManager()->parseUrl(Yii::app()->getRequest()->requestUri));



but I get this error:




Fatal error:  Call to a member function getPathInfo() on a non-object in /mnt/win_d/www/website/latihan/yii/framework/web/CUrlManager.php on line 297



any one can help me please!!

thank you for all

CHttpRequest::getRequest()->requestUri is a string, whereas CUrlManager::pasreUrl() expects a CHttpRequest object.

This is valid:


Yii::app()->getUrlManager()->parseUrl(Yii::app()->getRequest())

Edit: although, I suppose, not generally needed, as this should give the same result as


Yii::app()->getRequest()->requestUri

Oh… yes thank, but sir. how if I want to get a url parsed. I means like.

eg: http://myapp.com/index.php/products/id/6

that above link is generated using


Yii::app()->createUrl(array('/products','id' => 6))



how to parse that link (http://myapp.com/index.php/products/id/6) into


array('/products','id' => 6))

any idea sir?

I don’t know if this is available in core Yii (I’m not that experienced, so don’t take my word for it). The second part (‘id’=>6) you can get from the $_GET array. The first bit you could get from Yii::app()->controller->id. If there is an action as well (e.g., ‘/products/update’) I guess you’d have to make your own parse function.

Ow great sir, your reply is very useful for me, yes If in yii don’t provide this function, maybe I will make own…

thanks sir :slight_smile: