I Learning a framework Kohana.

What is difference between Kohana::message and Kohana::config?

They perform the same function. Maybe if there is a difference between the concept?

有帮助吗?

解决方案

Kohana:message

These are generally used to store messages that will be displayed to the user. For example if you have a method that tries to create a user and it fails, you can get the relevant you can you may have the following in a User Controller:

$create = $this->create_user($user);

if($create)
{
    // user created
    $message = Kohana::message('user', 'create_success');
}
else
{
    // failed to create user
    $message = Kohana::message('user', 'create_error');
}

Kohana:config

This is used for configuration information such as the hash_method used in auth module and you can access it using Kohana::$config->load('auth.hash_method')

其他提示

One is for configuration information. The other is for reusable text: Kohana::message('registration.error.email') could say something like "There is already an account using the email address you entered, an email with instruction on how to reset you password has been sent in case you forgot it.".

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top