I have the following code where I try to assign a value to a variable and then evaluate if it’s empty:
if(!empty($user = User::find($id))){
// do some operations on the $user
}
But I’m getting an error… Does the PHP compiler allows this in any way?
PS. I’m using PHP 5.3
Generally if a function cant find something, ie a User, then it would return
falseanyway – so this is what I normally do: