Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はphpスクリプトに大量の変数を持っています。最適性はどうですか、このデータを個々の変数に保存します
$a = "aaa"; $b = "bbb"; $c = "ccc";
または連想配列で?
$mas = array("a"=>"aaa","b"=>"bbb","c"=>"ccc");
どちらの方法が良いですか?または違いはありませんか?
場合によります。
同じコンテキスト内で変数の配列を作成することをお勧めします。例:
$config = array();
すべての構成変数を配列に格納できます。もちろん、スクリプトの実行に必要な他の変数はそこにあるべきではありません。