mardi 12 juin 2018

Why I can't use isset() with laravel $request->input('key')

These two snippets are the same

1)

if(isset($request->input('optionId'))){
  ....
  ....
  ....
  // statements will go here 
}

2)

$optionId = $request->input('optionId');

if(isset($optionId)){
  ....
  ....
  ....
  // statements will go here 
}

when first attempt, IDE says there is a syntax error. When I saved it and run the interpreter says

"Cannot use isset() on the result of an expression (you can use "null !== expression" instead)"

but the second one is executing fine.

my question is its the same when its assigned to $optionId right? Why is it running in second attempt and not in the first attempt .. what is the difference?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire