create a file named whatever you like in Application/config folder with following code:
<?php defined('SYSPATH') or die('No direct script access.');
return array(
'name' => 'William',
'Quote' => "To be or not to be."
);
Create an action method (function) in the controller (test.php) like so:
public function action_configtest()
{
echo Kohana::$config->load('myconfig.name');
}
Hit the url: http://localhost/project/test/configtest. You should see 'William' on the screen.
Like get, you can set a config variable:
public function action_configtest()
{
Kohana::$config->load('myconfig')->set('einstein','e=mc^2');
echo Kohana::$config->load('myconfig')->get('einstein');
}
Hit the url: http://localhost/project/test/configtest. You should see 'e=mc^2' on the screen.
<?php defined('SYSPATH') or die('No direct script access.');
return array(
'name' => 'William',
'Quote' => "To be or not to be."
);
Create an action method (function) in the controller (test.php) like so:
public function action_configtest()
{
echo Kohana::$config->load('myconfig.name');
}
Hit the url: http://localhost/project/test/configtest. You should see 'William' on the screen.
Like get, you can set a config variable:
public function action_configtest()
{
Kohana::$config->load('myconfig')->set('einstein','e=mc^2');
echo Kohana::$config->load('myconfig')->get('einstein');
}
Hit the url: http://localhost/project/test/configtest. You should see 'e=mc^2' on the screen.
No comments:
Post a Comment