Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Jak przekazać dane?
eminiasty
post 21.12.2017, 23:37:21
Post #1





Grupa: Zarejestrowani
Postów: 267
Pomógł: 0
Dołączył: 11.09.2015

Ostrzeżenie: (0%)
-----


Mam klase nadrzedna MY_Controller
  1. class MY_Controller extends CI_Controller
  2. {
  3.  
  4. function __construct()
  5. {
  6. parent::__construct();
  7. }
  8.  
  9. function index (){
  10. $logged_in = $this->session->userdata('logged_in');
  11. $data['login'] = $logged_in['login'];
  12. }
  13. }


oraz klase z niej dziedziczaca:

  1. class Main extends MY_Controller
  2. {
  3. function __construct()
  4. {
  5. parent::__construct();
  6. }
  7.  
  8. public function index()
  9. {
  10. $this->load->view('main/nav.php',$data);
  11.  
  12. }
  13. }


Jak sprawić by
  1. $data['login'] = $logged_in['login'];

czyli
  1. $data);

było dostepne w klasie Main
obecnie podkresla na czerwono

i jest błąd typu:
  1. Message: Undefined variable: login
( w widoku)

Ten post edytował eminiasty 21.12.2017, 23:37:45
Go to the top of the page
+Quote Post
aras785
post 21.12.2017, 23:42:55
Post #2





Grupa: Zarejestrowani
Postów: 859
Pomógł: 177
Dołączył: 29.10.2009

Ostrzeżenie: (0%)
-----


  1. class MY_Controller extends CI_Controller
  2. {
  3. public $data;
  4. function __construct()
  5. {
  6. parent::__construct();
  7. $logged_in = $this->session->userdata('logged_in');
  8. $this->data['login'] = $logged_in['login'];
  9. }
  10. }


  1. class Main extends MY_Controller
  2. {
  3. function __construct()
  4. {
  5. parent::__construct();
  6. }
  7.  
  8. public function index()
  9. {
  10. $this->load->view('main/nav.php',$this->data);
  11.  
  12. }
  13. }


Ten post edytował aras785 21.12.2017, 23:50:04
Go to the top of the page
+Quote Post
eminiasty
post 21.12.2017, 23:46:35
Post #3





Grupa: Zarejestrowani
Postów: 267
Pomógł: 0
Dołączył: 11.09.2015

Ostrzeżenie: (0%)
-----


występuje ten sam błąd
Go to the top of the page
+Quote Post
aras785
post 21.12.2017, 23:50:43
Post #4





Grupa: Zarejestrowani
Postów: 859
Pomógł: 177
Dołączył: 29.10.2009

Ostrzeżenie: (0%)
-----


Cytat(eminiasty @ 21.12.2017, 23:46:35 ) *
występuje ten sam błąd


Poprawiłem kod.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 23.04.2024 - 19:16