0

I have file error.log

[Sun Jan 27 08:42:09.476142 2019] [fcgid:warn] [pid 28535] mod_fcgid: stderr: PHP Notice: Only variables should be passed by reference in /var/www/mysite/data/www/mysite.io/core/Classes/Lang.php on line 90

[Sun Jan 27 08:42:09.476145 2019] [fcgid:warn] [pid 28535] mod_fcgid: stderr: PHP Notice: Undefined offset: 1 in /var/www/mysite/data/www/mysite.io/core/Classes/Router.php on line 97

[Sun Jan 27 08:42:18.984905 2019] [fcgid:warn] [pid 28533] mod_fcgid: stderr: PHP Notice: Undefined offset: 1 in /var/www/mysite/data/www/mysite.io/core/Classes/Router.php on line 29, referer: https://mysite.io/en/

[Sun Jan 27 08:42:18.984922 2019] [fcgid:warn] [pid 28533] mod_fcgid: stderr: PHP Notice: Undefined offset: 1 in /var/www/mysite/data/www/mysite.io/core/Classes/Router.php on line 97, referer: https://mysite.io/en/

[Sun Jan 27 08:42:26.384808 2019] [fcgid:warn] [pid 28531] mod_fcgid: stderr: PHP Notice: Undefined offset: 1 in /var/www/mysite/data/www/mysite.io/core/Classes/Router.php on line 29, referer: https://mysite.io/ru/

[Sun Jan 27 08:42:26.384831 2019] [fcgid:warn] [pid 28531] mod_fcgid: stderr: PHP Notice: Undefined offset: 1 in /var/www/mysite/data/www/mysite.io/core/Classes/Router.php on line 97, referer: https://mysite.io/ru/

File Router.php

protected function prepare()
 {
    $url = trim($this->server->get(static::SERVER_KEY), '/');
    @list($root, $query) = explode('?', $url);

    list($lang, $requestUrl) = explode('/', $root, 2); //line 29

    if($this->server->is('POST')) {
        $requestUrl = $lang;
    } else {
        if(in_array($lang, [Lang::LANG_RU, Lang::LANG_EN]) && $lang == config('language.default')) {
            header('Location: /' . $requestUrl);
            die;
        }

        if(
            !in_array($lang, [Lang::LANG_RU, Lang::LANG_EN])
        ) {
            $requestUrl = $url;
            $lang = config('language.default');
        }

        if(
            in_array($lang, [Lang::LANG_RU, Lang::LANG_EN])
            && $lang != lang()->lang()
        ) {
            lang()->setLanguage($lang);

            if($lang == config('language.default')) {
                header('Location: /' . $requestUrl);
            } else {
                header('Location: /' . lang()->lang() . '/' . $requestUrl);
            }

            die;
        }
    }

    $this->url = $requestUrl;
    $this->full_url = $url;
    $this->query = $query;
    $this->params = $this->parseQuery($query);
    $this->arguments = $this->parseArguments($url);
}



protected function parseArguments($url)
 {
    $segments = explode('/', $url);

    $data = [];
    foreach ($segments as $segment) {
        if(in_array($segment, [Lang::LANG_RU, Lang::LANG_EN])) { //line 97
            continue;
        }

        $data[] = $segment;
    }
    return $data;
}

File lang.php

protected function parseFromRaw($raw)
{
$lang = array_shift(explode(',', $raw)); //line 90

return in_array($lang, array_keys($this->getLanguagesList()))
    ? $lang
    : $this->defaultLanguage();
}
Fibo
  • 1
  • 1
  • Possible duplicate of ["Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" using PHP](https://stackoverflow.com/questions/4261133/notice-undefined-variable-notice-undefined-index-and-notice-undefined) – Paul T. Jan 27 '19 at 18:14
  • sorry I don't know how edit my code because I don't know php, pls help me – Fibo Jan 27 '19 at 18:33

0 Answers0