-3

I am using codeigniter php framework and I have faced with the following code during using Model in codeigniter so plz comment me how to solve it Thanks!

Parse error: syntax error, unexpected '[' in C:\wamp\www\codeigniter\CodeIgniter-3.1.10\application\models\My_model.php on line 6

A PHP Error was encountered Severity: Parsing Error

Message: syntax error, unexpected '['

Filename: models/My_model.php

Line Number: 6

Backtrace:

<?php
class My_model extends CI_Model{
    public function info()
    {
        return ["username" => "Nazir","Password" => "1122"];
    }
}
?>
M. Eriksson
  • 13,450
  • 4
  • 29
  • 40

1 Answers1

1

you are using the older version of PHP. You need to use array() to instantiate arrays in the older version of PHP:

class My_model extends CI_Model{
    public function info()
    {
        $result=array("username" => "Nazir","Password" => "1122");
        return $result;
    }
}
Shubham Azad
  • 786
  • 2
  • 10
  • 25