J
J
Jony13372016-12-04 20:41:09
CodeIgniter
Jony1337, 2016-12-04 20:41:09

Why can't I output function in function, php?

Hello
Is it possible in php to call a function inside another function, here is the code

public function redactpost($id) {
   if($this->session->userdata('logged_in'))
   {
     $session_data = $this->session->userdata('logged_in');
   $this->load->model('info_site');
$data =$this->info_site->get_info_post($id);
//print_r ($data);
 $inFo ['Titlu'] = $data[0]['Titlu'];
$inFo ['PozaDeTitlu'] = $data[0]['PozaDeTitlu'];
$inFo ['Autorul'] = $data[0]['Autorul']; 
 $inFo ['Data'] = $data[0]['Data'];
$inFo ['Stirea'] = $data[0]['Stirea'];
$inFo ['id'] = $data[0]['id'];

     $this->load->view('redactpost', $inFo);

   }
   else
   {
     //If no session, redirect to login page
     redirect('login', 'refresh');
   }
 }
 
 
 
 
 
 
 public function redactnew ($id) {
   if($this->session->userdata('logged_in'))
   {
$session_data = $this->session->userdata('logged_in');
     	

  $this->load->model('info_site');


  
$dk['Titlu'] = $this->input->post('titlu');
$dk['PozaDeTitlu'] = $this->input->post('linkPozaPrincipala');
$dk['Autorul'] = $this->input->post('NamePub');
$dk['Data'] = $this->input->post('data');
$dk['Stirea'] = $this->input->post('noutatea');
$dm['id'] = $id;
$this->info_site->edit_db_blog($dk,$id); 

redactpost($id);

   }
   else
   {
     //If no session, redirect to login page
     redirect('login', 'refresh');
   }
 }

redactnew () edits the data in the database, I want to display redactpost () again after that, but I get a
Fatal error: Call to undefined function redactpost ()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Cat Anton, 2016-12-04
@27cm

Since this is a class method, then call it as a class method Understand $this->redactpost($id);
the basics: php.net/oop

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question