2
$profilePic = isset( $userservice->getProfilePic($userid))      
              ?  filter($userservice->getProfilePic($userid)) 
              : '<img></img>';

Returns the error:

Fatal error: Can't use method return value in write context

What am I doing wrong here?

Nanne
  • 64,065
  • 16
  • 119
  • 163
Paul Dessert
  • 6,363
  • 8
  • 47
  • 74

3 Answers3

9

You can only use isset with variables, not with return values from functions, as isset is not a function, but a language construct.

addendum: There was a vote to allow passing arbitrary expression arguments to isset and empty, but finally isset was dropped from the final implementation.

Carlos Campderrós
  • 22,354
  • 11
  • 51
  • 57
3

isset only and exclusively works on variables. You do not need it for functions. Your ternary operator is fine.

See The Definitive Guide To PHP's isset And empty.

deceze
  • 510,633
  • 85
  • 743
  • 889
0

try: "

$tempPic=$userservice->getProfilePic($userid);
         $profilePic = isset($tempPic ) ?  filter($userservicegetProfilePic($userid))  : '<img></img>';

"

ka_lin
  • 9,329
  • 6
  • 35
  • 56