CodeIgniter Forums
[Solved] Getting Error Function name must be a string - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: [Solved] Getting Error Function name must be a string (/showthread.php?tid=65783)



[Solved] Getting Error Function name must be a string - wolfgang1983 - 07-23-2016

I am getting this error below


PHP Code:
Fatal error: Function name must be a string in C:\xampp\htdocs\cookie\application\controllers\Welcome.php on line 23
A PHP Error was encountered

Severity
Error

Message
: Function name must be a string

Filename
controllers/Welcome.php

Line Number
23

Backtrace



I am trying to set a if statement so if cookie time has expire will be delete any suggestions on better time expire check.


PHP Code:
<?php

defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Welcome extends CI_Controller {

    public 
$expire_for_cookie 1440;

    public function 
__construct() {
        
parent::__construct();
    }

    public function 
index() {
        
$remember $this->input->post('remember');

        if (isset(
$remember)) {
            
$this->write_cookie($remember);
        }

        
$current_time time();
        
$expire_time $this->set_cookie_delete_time();

        if(
$current_time() > $expire_time) { // Line 23
            
$this->delete_cookie();
         
   echo "Your cookie has been removed";
        } 

        
$this->load->view('welcome_message');
    }

    public function 
write_cookie($remember TRUE) {
        
setcookie('remember'$remember $this->set_cookie_expire_time(), '/''.localhost');
    }

    public function 
delete_cookie() {
        
setcookie('remember''' $this->set_cookie_delete_time(), '/''.localhost');
    }

    public function 
set_cookie_expire_time() {
        return 
time() + $this->expire_for_cookie;
    }

    public function 
set_cookie_delete_time() {
        
// From Database But At The Moment Just Set Manually
        
return time() - $this->expire_for_cookie;
    }




RE: Getting Error Function name must be a string - PaulD - 07-24-2016

Line 23, $current_time() should be $current_time without the brackets.


RE: Getting Error Function name must be a string - wolfgang1983 - 07-24-2016

(07-24-2016, 04:05 AM)PaulD Wrote: Line 23, $current_time() should be $current_time without the brackets.

Thanks silly mistake by me brain not thinking.