PHP奇怪的解析错误

So I'm pulling my hair out at this point :/

I've got an IIS webserver set up with PHP 7.1.11 on Windows Server 2012 R2 Datacenter Edition , when I load up a page it throws a parse error:

Parse error: syntax error, unexpected '[' in functions.php on line 138

Now the actual piece of code where this goes wrong is the following

$hash = password_hash($nieuwWachtwoord,PASSWORD_DEFAULT, ["cost" => 13]);

And when I changed it to

$hash = password_hash($nieuwWachtwoord,PASSWORD_DEFAULT,array("cost" => 13));

It executes the code without any problem.

But then when I called another function running the following code

 Database::fetch_assoc("SQL-STRING", array($id))[0]['cdate'];

It also throws a parse error. The frustrating thing is that this shouldn't happen since declaring an array like that on the go should be possible in php7.1 (and this same code on a Linux machine running ubuntu with apache2 works like it should)

Also the last case where I "assume" an array is returned should at most throw an undefined index error instead of a parse error.

Does anyone know what the cause may be?

Thanks in advance!

查看全部
dongzhi6927
dongzhi6927
2017/11/20 01:26
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复