Search code examples
phpcrypt

crypt password get Parse error: syntax error, unexpected '[' in


i developed mvc with php and mysql and pdo in hosting the site appeared this problem in the admin control panel i created its in the login controller

the problem is as shown in browser

Parse error: syntax error, unexpected '[' in /home/trustlabseg/public_html/test/app/C_LoginController.php on line 21

i searched for all the same error in here and its not like that no one solve my problem

the code is

  $password = crypt($_POST['password'], PASSWORD_BCRYPT, ['cost' => 12]);

    $rules = [
                    "username" => "checkReguired|checkStrings",
                    "password" => "checkReguired"
     ];

when i delete the last line the page load but still canot loging please little help here and thanks alot


Solution

  • Use array() for older PHP versions. Additionally, it is spelled "required" (as in to require).

    $password = crypt($_POST['password'], PASSWORD_BCRYPT, array('cost' => 12));
    $rules = array("username" => "checkRequired|checkStrings", "password" => "checkRequired");