Reputation: 53
Whats wring with this code?
if(isset($this->session->flashdata('login_error'))) { // Line 39
echo "You entered an incorrect email or password!";
}
I use Codeigniter and session is loaded in autoload.php
.
The error message I get is:
Fatal error: Can't use method return value in write context in /Applications/XAMPP/xamppfiles/htdocs/application/views/login_view.php on line 39
Upvotes: 5
Views: 2204
Reputation: 1492
just checking if($this->session->flashdata('login_error')) will return false if the result of this function is a boolean FALSE or NULL
Upvotes: 1
Reputation: 3523
isset
only checks if a variable in instantiated. Since you can only return instantiated variables, isset
is invalid there. Your best bet would be to do it like:
if($this->session->flashdata('login_error') != null) { // Line 39
echo "You entered an incorrect email or password!";
}
Upvotes: 1
Reputation: 91752
You can´t use a function with isset
like that. What you could do is something like:
$txt = $this->session->flashdata('login_error');
if(!empty($txt))
{
echo "You entered an incorrect email or password!";
}
Upvotes: 1
Reputation: 522412
isset
is only necessary if you're trying to work with variables that may not exist. In your case you're calling a function, which certainly exists. Hence you don't need and in fact can't use isset
here. Just use if ($this->session->flashdata('login_error'))
if you want to test whether the value is truthy.
Upvotes: 12