yii\web\Request::getUrl PHP Méthode

getUrl() public méthode

This refers to the portion of the URL that is after the [[hostInfo]] part. It includes the [[queryString]] part if any.
public getUrl ( ) : string
Résultat string the currently requested relative URL. Note that the URI returned is URL-encoded.
    public function getUrl()
    {
        if ($this->_url === null) {
            $this->_url = $this->resolveRequestUri();
        }
        return $this->_url;
    }

Usage Example

 public function getUrl()
 {
     if ($this->langUrl === null) {
         $this->langUrl = parent::getUrl();
         $this->originalUrl = $this->langUrl = parent::getUrl();
         $scriptName = '';
         if (strpos($this->langUrl, $_SERVER['SCRIPT_NAME']) !== false) {
             $scriptName = $_SERVER['SCRIPT_NAME'];
             $this->langUrl = substr($this->langUrl, strlen($scriptName));
         }
         Yii::$app->getModule('radiata')->getActiveLanguageByUrl($this->langUrl);
         if (Yii::$app->getModule('radiata')->activeLanguage->code) {
             Yii::$app->language = Yii::$app->getModule('radiata')->activeLanguage->locale;
             if (Yii::$app->getModule('radiata')->activeLanguage->code != Yii::$app->getModule('radiata')->defaultLanguage->code) {
                 $this->langUrl = substr($this->langUrl, strlen(Yii::$app->getModule('radiata')->activeLanguage->code) + 1);
             }
         }
         if (!$this->langUrl) {
             $this->langUrl = $scriptName . '/';
         }
     } else {
         $this->langUrl = parent::getUrl();
     }
     return $this->langUrl;
 }
All Usage Examples Of yii\web\Request::getUrl