J
J
Joe Moose2017-01-08 02:59:56
MySQL
Joe Moose, 2017-01-08 02:59:56

Yii2 can you help with the launch?

It shows
PHP Parse Error - yii\base\ErrorException
syntax error, unexpected 'else' (T_ELSE), expecting function (T_FUNCTION)
1. in C:\OpenServer\domains\yii.local\vendor\yiisoft\yii2\web\ Request.php at line 1272
1263126412651266126712681269127012711272127312741275127612771278127912801281 $data = @unserialize($data);
if (is_array($data) && isset($data[0], $data[1]) && $data[0] === $name) {
$cookies[$name] = new Cookie([
'name' = > $name,
'value' => $data[1],
'expire' => null,
]);
!it shows an error } else { ------------------------------------- -XXXX
foreach ($_COOKIE as $name => $value) {
$cookies[$name] = new Cookie([
'name' => $name,
'value' => $valu,
'expire' => null,
] );
}
}
points red to the line } else {
then I open the request file
and don't know what to fix there
/**
* Converts `$_COOKIE` into an array of .
* return array the cookies obtained from request
* @throws InvalidConfigException if is not set when is true
*/
protected function loadCookies()
{
$cookies = [];
if ($this->cookieValidationKey == '') {
throw new InvalidConfigException(get_class($this) . '::cookieValidationKey must be configured with a secret key.');
}
foreach ($_COOKIE as $name => $value) {
if (!is_string($value)) {
continue;
}
$data = Yii::$app->getSecurity()->validateData($value, $this->cookieValidationKey);
if ($data === false) {
continue;
}
$data = @unserialize($data);
if (is_array($data) && isset($data[0], $data[1]) && $data[0] === $name) {
$cookies[$name] = new Cookie([
'name' = > $name,
'value' => $data[1],
'expire' => null,
]);
}
}
!here } else { ------------------------------------- ------------XXXXXX
foreach ($_COOKIE as $name => $value) {
$cookies[$name] = new Cookie([
'name'
'value' => $valu,
'expire' => null,
]);
}
}
return $cookies;
}
private $_csrfToken;
/**
* Returns the token used to perform CSRF validation.
*
* This token is generated in a way to prevent [BREACH attacks]( breachattack.com/). It may be passed
* along via a hidden field of an HTML form or an HTTP header value to support CSRF validation.
* @param boolean $regenerate whether to regenerate CSRF token. When this parameter is true, each time
* this method is called, a new CSRF token will be generated and persisted (in session or cookie).
* return string the token used to perform CSRF validation.
*/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rou1997, 2017-01-08
@Rou1997

1. in C:\OpenServer\domains\yii.local\vendor\yiisoft\yii2\web\Request.php

This file should be correctly replaced with the original one (unless, of course, you edit the "core" of the framework), if the problem remains, then it is not in this file, but outside it, do you at least use Notepad ++? It simplifies the detection of errors with missing brackets.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question