php - CodeIgniter variables in constructor -



looked topics around, didn't see case.
so, have controller filled methods, , construcor loads models commonly use in specific controller. works fine. needed set array in constructor like

$data["content"]["something"] = "bla bla"; 

thats all. pass $data["content"] view loader, , i'm expecting have access

$something 

, no. takes undefined variable, why? when put in specific method works fine, when in constructor says undefined. ideas? thank you! :)

you cannot access constructor variables in view. need pass controller's method , pass view. example,

in constructor :

$data["content"]["something"] = "bla bla"; 

in controller's method :

$data['something'] = $this->$data["content"]["something"]; 

now can pass $data view , access echo $something;


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -