0

This is the code for the function:

function isPresent($field)
{
    return (isset($field) && !empty(trim($field)));
}

I am trying to validate a field in a form that is not empty. When I run the php, the error: Can't use function return value in write context shows up.

Andy
  • 127
  • 2
  • 9

1 Answers1

0

From the php manual for empty():

Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error. In other words, the following will not work: empty(trim($name)). Instead use trim($name) == false.

Stevish
  • 734
  • 5
  • 17
  • 1
    how can you still answer after its closed as duplicate. –  Nov 18 '16 at 02:11
  • Huh, I dunno. It took me a while to post the answer because this app on my phone won't let me paste. Had to type the stupid thing out manually while switching back and forth between apps. Maybe the site would work better... – Stevish Nov 18 '16 at 02:14
  • ok was not complaining, just it shouldn't be possible. –  Nov 18 '16 at 02:18
  • 1
    I really think it's this demon possessed app that let me do it... – Stevish Nov 18 '16 at 02:26
  • nice i need to get me on of those. :-0 –  Nov 18 '16 at 02:55