on the following lines I get the error 'String offset cast occured'
$code[$value['dictionaryAlias']] = $value['dictionaryText'][$codeLang];
$code[$value['dictionaryAlias']] = $value['dictionaryText'][$langDefault];
Actually, the code access a table. It works in previous version but not in 5.4
I am a newbie and I am in charge in converting the code. What changes should I make to make it work. I read that it is probably because the variable is a string instead of an array. What can I do then?
This means that $value['dictionaryText']
is a string, and either $codeLang
or $langDefault
is not an integer. The indexing operator works on strings, but only accepts integer indices: when it receives something else, it tries to convert it to an integer, most often resulting in the value 0, and returns the character at that index.
This is a new warning that they introduced in 5.4 because it was a frequent mistake and a frequent cause of headaches.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With