0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

php7.4から波括弧を使用した配列や文字列のオフセットへのアクセスは非推奨になる

Posted at

php7.4から波括弧を使って配列や文字列のオフセットにアクセスする文法は推奨されなくなります。

$var{$idx} でなはく $var[$idx] を使って下さい。

$a = [100, 2, 3, 4, 5, 'a' => 'hoge'];
var_dump($a{'a'});
// 出力
string(4) "hoge"

こういう書き方は注意ですね。

というか波括弧でも配列のオフセット指定が動くって知らなかった。。。

波括弧を使った、配列や文字列のオフセットへのアクセス

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?