How, in Yii, to get the current page's URL. For example:
http://www.yoursite.com/your_yii_application/?lg=pl&id=15   but excluding the $GET_['lg'] (without parsing the string manually)?
I mean, I'm looking for something similar to the Yii::app()->requestUrl / Chtml::link() methods, for returning URLs minus some of the $_GET variables.
Edit: Current solution:
unset $_GET['lg'];  echo Yii::app()->createUrl(   Yii::app()->controller->getId().'/'.Yii::app()->controller->getAction()->getId() ,    $_GET  ); 
                The simplest solution would be: echo parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
Answer: Use the PHP $_SERVER Superglobal Variable You can use the $_SERVER built-in variable to get the current page URL in PHP. The $_SERVER is a superglobal variable, which means it is always available in all scopes.
Yii::app()->request->getUrl() method is used to get current url in Yii framework.
Yii::app()->request->url  Yii::$app->request->url 
                        Yii::app()->createAbsoluteUrl(Yii::app()->request->url)   This will output something in the following format:
http://www.yoursite.com/your_yii_application/ 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With