CodeIgniter Forums
Fatal error: Cannot use string offset as an array in .... user_view.php on line 12 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Fatal error: Cannot use string offset as an array in .... user_view.php on line 12 (/showthread.php?tid=43198)



Fatal error: Cannot use string offset as an array in .... user_view.php on line 12 - El Forum - 07-04-2011

[eluser]Unknown[/eluser]
Hi, I was receiving this type of error my times in codeigniter, The main issue that I have found and resolved this error is following!

1- If we are providing wrong file name and class name used in file then generate that type of error. e.g

file name is user_school_info.php and class name that we have defined in that file is
Code:
class School_info {
}
then I have got this type of error.

2- If I am returning an array of naming index and retrieving with different name then found this type of error! e.g

return array as
Code:
$users['info']['teacher']
and trying to retrieve in view class as an different name.

3- Appending an array after a string e.g
Code:
$user = 'test';
  $user['info'] = 'Our data'

Appending an array after string also display that type of error! So make sure that we have create an array for array values! :-)




Hoping this tutorial will help you to understand why we receive this type of error!