I didn’t have problem with this function in php 5.4 but in upgrading script i have this probem. my function in the function.php file through which I call the language files of the project.
class sblib {
var $sblang = "";
var $lang = "";
function load_lang($file_lang) {
global $sbportals;
$mlang = $this->sblang;
if ($sbportals->member['sb_lang']) {
$dir = @opendir($this->sitepath."sbportal/lang/");
while (($dirt = readdir($dir)) !== false) {
$sbl = strtolower (substr($dirt, 0, 3));
$bol = strtolower (substr($sbportals->member['sb_lang'], 0, 3));
if ($sbl == $bol && $dirt != ".htaccess" && $dirt != "htaccess" && $dirt != "index.html" && $dirt != "English_Reference") {
$mlang = $this->sitepath."sbportal/lang/".$dirt;
}
}
closedir($dir);
}
require "$mlang/$file_lang";
foreach ($langsb as $k => $v) {
$this->lang[$k] = stripslashes($v);////this line///
}
}
$sblib = new sblib;
$sblib->stimer();
$sblib->sblang = $sb_PATH."sbportal/lang/".$sb_LANG;
This is the content of the language file (lang_search.php):
$langsb['ad_langs_group'] = "Group";
$langsb['ad_langs_group_title'] = "Group Title";
$langsb['ad_langs_sel_title'] = "Language Administration";
$langsb['ad_langs_sel_info'] = "Choose the language";
Then by calling the function (once in each file of the project) as follows
$sblib->load_lang("lang_search.php");
And using the calling function wherever I need as below
{$sblib->lang['download']}
I can use translation files for translate of each words. I had no problem until php 5.6, but I see this error when upgrading to 7.4.
Warning: Illegal.string.offset.'download'.in ... (////this line///)
please help me to solve.
I have checked all the ways and pages of the stackoverflow.