mirror of
https://github.com/php/php-src.git
synced 2024-12-14 04:16:30 +08:00
9fa70dbd29
There is one case that requires further discussion: $foo = "test"; var_dump($foo[0.0] ?? "default"); var_dump(isset($foo[0.0]) ? $foo[0.0] : "default"); Here the former will currently return "t", while the latter also returns "t" and additionally throws a notice. I think we need to revisit the behavior of invalid types for string offset access in PHP 7, as currently there is some mismatch between what isset() does and what the access itself supports.
23 lines
423 B
PHP
23 lines
423 B
PHP
--TEST--
|
|
Bug #69889: Null coalesce operator doesn't work for string offsets
|
|
--FILE--
|
|
<?php
|
|
|
|
$foo = "test";
|
|
var_dump($foo[0] ?? "default");
|
|
|
|
var_dump($foo[5] ?? "default");
|
|
var_dump(isset($foo[5]) ? $foo[5] : "default");
|
|
|
|
var_dump($foo["str"] ?? "default");
|
|
var_dump(isset($foo["str"]) ? $foo["str"] : "default");
|
|
|
|
?>
|
|
--EXPECT--
|
|
string(1) "t"
|
|
string(7) "default"
|
|
string(7) "default"
|
|
string(7) "default"
|
|
string(7) "default"
|
|
|