Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP error, if-statement

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

like image 934
Loka Avatar asked Mar 23 '11 13:03

Loka


1 Answers

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.

like image 177
deceze Avatar answered Oct 13 '22 23:10

deceze