简体   繁体   中英

isset() working in php5.6 but not in php7.0

I have a code base that I am trying to migrate to 7.0.

In the code, I have something like: isset($user['details']['phone_no']) where $user is an object of User. This works fine in php5.6. where as in php7 it returns false. when doing var_dump($user['details']['phone_no']) it is returning a string.

It works fine when I change the code from:

$phone_no = isset($user['details']['phone_no']) ? $user['details']['phone_no'] : 'XXXXXXXXXX'; 

to:

$phone_no = $user->details->phone_no ?? 'XXXXXXXXXX';

However, the codebase is too huge to refactor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM