Help me find a mistake, I have already rechecked everything 20 times.

Produces Parse error: syntax error, unexpected '?' in D: \ wordpress \ openserver \ OpenServer \ domains \ php-framework-master \ application \ models \ Main.php on line 35

Here is the code from lines 31-35

public function postsList($route) { $max = 10; $params = [ 'max' => $max, 'start' => ((($route['page'] ?? 1) - 1) * $max), ]; return $this->db->row('SELECT * FROM posts ORDER BY id DESC LIMIT :start, :max', $params); } 

after it came out Notice points to the line

 'list' => $this->model->postsList($this->route['page']), 

all code

 public function indexAction() { $pagination = new Pagination($this->route, $this->model->postsCount()); $vars = [ 'pagination' => $pagination->get(), 'list' => $this->model->postsList($this->route['page']), ]; $this->view->render('Главная страница', $vars); } 

    1 answer 1

    ?? there is only new php. Maybe this is the problem. Can be replaced by ?:

    • tried already, in replacements the error Parse error: syntax error, unexpected ')' in D: \ wordpress \ openserver \ OpenServer \ domains \ php-framework-master \ application \ models \ Main.php on line 35 falls out
    • @ AlekseySokol and what is your php? I tried both options, the linter show that they are valid - Neo New
    • version - php 5.4 - Alexey Sokolov
    • @ I checked AlexeySokolov, at 5.4 'start' => ((($route['page'] ?: 1) - 1) * $max), works - Neo New
    • it seemed to help, but the error came out on the next code, you can please see what is wrong, added the question above - Alexey Sokolov