cakephp2.doc_011
最終投稿日:2019年11月20日
[app/Config/bootstrap.php]
【共通ファイルの読み込み】
//『app/Config/app_const.php』ファイルを読み込みます
Configure::load('app_const');
例)
『app_const.php』
<?php
$config['Const'] = array(
define('COMPANY_NAME','あああ'),
"test_1" => array(
"abc" => "123",
"def" => "456",
"ghi" => "789"
),
"test_2" => array(
"abc" => "147",
"def" => "258",
"ghi" => "369"
),
);
?>
『コントローラ側』
function index(){
extract(Configure::read('Const'));
//上記のアクション内で『$config['Const']』の各インデックスを変数とした配列が取得できる。
$test_1 は array("abc" => "123","def" => "456","ghi" => "789")となる。