PHP Parse error: syntax error, Unexpected '[' - PHP 5.3.29

Asked

Viewed 38 times

2

I have an application running perfectly locally. But when I played it online I keep getting the following message and I have no data return.

PHP Parse error: syntax error, Unexpected '[' in /var/www/reporters.intercol.com.br/_app/Models/Reportarioos.class.php on line 118

My PHP version is 5.3.29

and the code in question would be.

private function _getTipoOs(int $codostipo){
       $tipoOS = new Read();
       $tipoOS->ExeRead($this->empresa, 'mk_os_tipo', 'WHERE codostipo = :cot', "cot={$codostipo}", "descricao");
       $this->result = $tipoOS->getResult()[0];
       return $this->result["descricao"];
    }

I thank everyone who can help.

  • php5.3 does not support this type of syntax $tipoOS->getResult()[0]; need to store the return of the function in a variable and then use the index zero $var[0]

  • Also unable to type parameters with primitive types, need to remove it from the signature. _getTipoOs(int $codostipo)

  • 1

    Vamo uses php >= 7 personal kkkkkkk..!

  • 1

    Drik, if it were up to me we would be using it anyway. syntax was that and I already went ahead and removed the int $codostipo. Thanks for the personal help.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.