Welcome Guest, Not a member yet? Register   Sign In
[Solved] Getting Error Function name must be a string
#1

(This post was last modified: 07-24-2016, 04:06 AM by wolfgang1983.)

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, 04: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




Theme © iAndrew 2016 - Forum software by © MyBB