2

我想描述如下定义的全局消息,但我不知道在哪里定义它以及如何使用它,如果有人可以帮助我..

<?php
    $messages=array(
            'JAVASCRIPT_DISABLED'=>'Please enable JavaScript in your browser or upgrade to a JavaScript-enable browser to use '.$site_name,
    );

$common_messages=array(
    'REQ'=>'requied',
    'EXISTS'=>' already exists',
    'ADDED'=>' added successfully',
    'MODIFIED'=>' modified successfully',
    'SIZE_EXCEED'=>'Invalid file format or size',

);


//ADMIN PANEL MESSAGE...
$validation_messages=array(
        'INVALID_EMAIL'=>'Valid email '.$common_messages['REQ'],
        'INVALID_PASSWORD'=>'Valid password '.$common_messages['REQ'],
        'INVALID_LOGIN'=>'Invalid login detail',
        'ACCOUNT_DISABLED'=>'Account disabled or Deleted by admin',
        'SIZE_EXCEED'=>'Invalid file format or size',
        'FILE_CANNOT_EMPTY'=>'File cannot be empty'
);

//NOTIFICATION FLAGS
$notify=array(
    'error'=>'m=e',
    'added'=>'m=a',
    'modified'=>'m=m'
);

?>

4

2 回答 2

5

在配置文件夹中创建文件,例如 messageerror.php

向其添加代码

$config['errormessage'] = your message here;

如果你想调用它。

$this->load->config('messageerror');

用这个$this->config->item('errormessage')

于 2012-12-31T12:38:03.897 回答
3

为什么不使用config/constants.php

您可以简单地添加常量,例如:

    define('ERROR_INVALID_EMAIL','Please provide a valid email address'); 
    define('NOTIFY_LOGGED_IN','You are now logged in'); 
   //... and so on
于 2012-12-31T14:27:37.990 回答