yii\web\Request::getPathInfo PHP Метод

getPathInfo() публичный Метод

A path info refers to the part that is after the entry script and before the question mark (query string). The starting and ending slashes are both removed.
public getPathInfo ( ) : string
Результат string part of the request URL that is after the entry script and before the question mark. Note, the returned path info is already URL-decoded.
    public function getPathInfo()
    {
        if ($this->_pathInfo === null) {
            $this->_pathInfo = $this->resolvePathInfo();
        }
        return $this->_pathInfo;
    }

Usage Example

Пример #1
0
 /**
  * Parses the given request and returns the corresponding route and parameters.
  * @param UrlManager $manager the URL manager
  * @param Request $request the request component
  * @return array|boolean the parsing result. The route and the parameters are returned as an array.
  * If false, it means this rule cannot be used to parse this path info.
  */
 public function parseRequest($manager, $request)
 {
     foreach ($this->skip as $item) {
         if (strpos($request->getPathInfo(), $item) !== false) {
             return false;
         }
     }
     $path = $request->getPathInfo();
     $redirect = false;
     // Слэш в конце
     if (substr($path, -1) == '/') {
         $redirect = true;
         $path = trim($path, '/');
     }
     // Двойной слэш
     if (strpos($path, '//') !== false) {
         $redirect = true;
         $path = str_replace('//', '/', $path);
     }
     // Символы в верхнем регистре
     if (($tmpUrl = strtolower($path)) !== $path) {
         $redirect = true;
         $path = $tmpUrl;
     }
     if ($redirect) {
         Yii::$app->response->redirect([$path], 301);
         Yii::$app->end();
     }
     return false;
 }
All Usage Examples Of yii\web\Request::getPathInfo