Migrating from PHP7.0 to 7.1 and type declaration

时间:2018-11-13 07:54:07

标签: migration php-7.1

I found a problem migrating some scripts, please consider this code:

 <?php
    $test="";
    ...
    $test["test"]=1;
    var_dump($test);

I expect an array as output, and this is what 7.0 do.

PHP 7.0

array(1) {
  ["test"]=>
  int(1)
}

But with 7.1 the type change doesn't happen and the variable remains a string.

PHP 7.1

string(1) "1"

I read the 7->7.1 changelog but I did not found this feature, can you confirm that this is a new feature?

0 个答案:

没有答案