News for hackers. Stuff that matters.
Re:46 useful PHP code snippets by oneeyedpigeon on Thursday August 06, 2015 @11:45AM (#10017245)
This doesn't look like the most professionally put together set of snippets I've ever seen. For example:

  function is_validemail($email)
  {
      $check = 0;

      if(filter_var($email,FILTER_VALIDATE_EMAIL))
      {
          $check = 1;
      }

      return $check;
  }
is a long-winded way of doing:

  function is_validemail($email)
  {
      return filter_var($email, FILTER_VALIDATE_EMAIL) ? 1 : 0;
  }
Re:46 useful PHP code snippets by tuananh on Thursday August 06, 2015 @11:49AM (#10017288)
from teh function name, i would expect boolean as return type.
Re:46 useful PHP code snippets by oneeyedpigeon on Thursday August 06, 2015 @11:54AM (#10017329)
To be fair, filter_var has a pretty screwy return type of its own but, yeah, if you're going to bother wrapping it, you might as well clean that up:

  return filter_var(...) !== FALSE;
might do it ...
Re:46 useful PHP code snippets by nkozyra on Thursday August 06, 2015 @11:52AM (#10017319)
Well, it basically is due to type juggling.
Re:46 useful PHP code snippets by sarciszewski on Thursday August 06, 2015 @11:50AM (#10017300)
Yeah, I would too.