• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Getting Error Function name must be a string

#1
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;
    }

There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply

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

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

Thanks silly mistake by me brain not thinking.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.