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?

PHP勉強メモ20250416 (配列の要素取得、キャメルケースかアンダースコアか)

Posted at

前回

配列の要素取得

  • 配列の要素取得は、基本的にキー名で行う
$array = [
    'apple' => 100,
    'banana' => 150,
    'orange' => 200,
];

echo $array['banana'];
array_values($array)[1]
  • キーのない配列の場合、自動でindexの数値のキーが振られるらしい
$array = ['a', 'b', 'c'];

echo $array[0]; // 出力: a

変数名はキャメルケースが書くかagain

前回も書いていたけれど、忘れていたのでもう一度。

CakePHPの場合は、変数名・メソッド名はキャメルケースで書く。
また、昔はメソッドがprivateの場合は_を頭につけていたが、今はprivateとつけられるので、メソッド名の頭の_は不要とのこと。

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?