From 4d6a665e042d6ddf757699e434e3d833a3af158f Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Fri, 1 Jul 2016 18:57:07 +0100 Subject: [PATCH] Small code optimisation: use strtr instead of str_replace (#709) --- application/config/config.php | 6 +++--- application/core/MY_Lang.php | 2 +- application/hooks/load_config.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/application/config/config.php b/application/config/config.php index 1dbf2036b..c106dcf1d 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -46,9 +46,9 @@ $config['ospos_xss_clean'] = TRUE; | a PHP script and you can easily do that on your own. | */ -$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http"); -$config['base_url'] .= "://".$_SERVER['HTTP_HOST']; -$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']); +$config['base_url'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; +$config['base_url'] .= '://' . $_SERVER['HTTP_HOST']; +$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); /* |-------------------------------------------------------------------------- diff --git a/application/core/MY_Lang.php b/application/core/MY_Lang.php index 70fe82fd6..60550190b 100644 --- a/application/core/MY_Lang.php +++ b/application/core/MY_Lang.php @@ -19,7 +19,7 @@ class MY_Lang extends CI_Lang foreach($loaded as $file) { - $this->load( str_replace( '_lang.php', '', $file ) ); + $this->load(strtr($file, '', '_lang.php')); } } } diff --git a/application/hooks/load_config.php b/application/hooks/load_config.php index e61b520bb..9d3e85f83 100644 --- a/application/hooks/load_config.php +++ b/application/hooks/load_config.php @@ -28,7 +28,7 @@ function load_config() { if(!is_array($file) && substr(strrchr($file,'.'), 1) == "php") { - $CI->lang->load(str_replace('_lang.php', '', $file), $language); + $CI->lang->load(strtr($file, '', '_lang.php'), $language); } } }