0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CodeIgniterカスタムまとめ

Posted at

メッセージカスタムめも

個人的なカスタム内容のまとめ
 もし、ツッコミ等あればお願いします

  開発と本番環境で表示するメッセージを自動で変更したい
  +
  メッセージファイル内でENVIRONMENTで分岐させたくない

index.php
switch (ENVIRONMENT)
{
    case 'local':
	case 'development':
	    define('ENVIRONMENT_COMMON', 'development');
		error_reporting(-1);
		ini_set('display_errors', 1);
	break;

	case 'testing':
	case 'production':
	    define('ENVIRONMENT_COMMON', 'production');

こんな感じでENVIRONMENT_COMMONを定義しておく。
使い方

$this->lang->load('error', 'japanese_'. ENVIRONMENT_COMMON);

application/language/japanese_development/error_lang.php
application/language/japanese_production/error_lang.php
を用意しておくと綺麗なメッセージファイルが記述できるようになる。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?