Live data from Hacker News

46 useful PHP code snippets

blog.koonk.com

1–10 of 26 posts

Re: 46 useful PHP code snippets

#2
I stopped at #3...using stripslashes is not an acceptable deterrent by any means. I am also unsure how htmlentities has anything to do with SQL injection...maybe you meant XSS prevention? I chose not to read the rest.

Re: 46 useful PHP code snippets

#5
post #2

I stopped at #3...using stripslashes is not an acceptable deterrent by any means. I am also unsure how htmlentities has anything to do with SQL injection...maybe you meant XSS prevention? I chose not to read the rest.

Yeah, just logged in to say that. Author probably never heard of PDO and parametrized queries...

Re: 46 useful PHP code snippets

#6
post #2

I stopped at #3...using stripslashes is not an acceptable deterrent by any means. I am also unsure how htmlentities has anything to do with SQL injection...maybe you meant XSS prevention? I chose not to read the rest.

Oh wow. So happy not having to read such things anymore.

Re: 46 useful PHP code snippets

#7
post #2

I stopped at #3...using stripslashes is not an acceptable deterrent by any means. I am also unsure how htmlentities has anything to do with SQL injection...maybe you meant XSS prevention? I chose not to read the rest.

100% agreed, I have the same sentiment. In the year 2015, everyone should know about injections and how to use prepared statements and similar insertion mechanisms that clearly separate query from data. A big no-no to solve anything with the presented function.

Re: 46 useful PHP code snippets

#8
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;
  }
Post reply on HN