Y
Y
Yevhenii K2015-11-09 18:03:02
PHP
Yevhenii K, 2015-11-09 18:03:02

What is wrong with []?

Good afternoon!
There is a code

<?php
class DB {
  private static $instance;
  private static $db;
  public static function obj() 
  {
    $class=get_called_class();
      if (is_null(self::$instance))
      {
        self::$instance=new $class;
        self::$db=new PDO("mysql:dbname=news_db;host=localhost","root","");
         
      }
      return self::$instance;
  }
    public function connect(){
       return self::$db;
     }
     public function queryAll($sql){
       
       $quer=$this->connect()->query($sql);
       if (is_null($quer)) {
        return [];
       }
       return $quer->fetchALL(PDO::FETCH_ASSOC);
     }
     public function queryOnce($sql){
       $quer=$this->connect()->query($sql);
       if (is_null($quer)) {
         return [];
       }
       return $quer->fetch(PDO::FETCH_ASSOC);
     }
     
   }
   $new_connect=DB::obj()->connect();

now the browser started swearing at
Parse error: syntax error, unexpected '[' in C:\OpenServer\OpenServer\domains\site.loc\php\classes\db.php on line 23
but a couple of days ago everything was working fine in the same form .
And so this error appears everywhere where there is a return [];.
I think that this is due to the update of openserver (it worked on the old version, but not on the new one), but I don’t know how to fix it (without rolling back to the old version). Help me please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Taratin, 2015-11-09
@AFI19

Settings -> Modules Set
PHP
5.6
Apache 2.4

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question