On the Advanced PHP Tutorial site there's a recent post that suggests a few useful functions that can get you started on security and protecting your application from possible exploits. These aren't the only way to prevent these issues, but they're a start in the right direction.
Security is a very important aspect of programming. In PHP, there are few useful functions which is very handy for preventing your website from various attacks like SQL Injection Attack , XSS attack etc.Let’s check few useful functions available in PHP to tighten the security in your project. But note that this is not a complete list, it just list of functions which I found useful for using in your project.
The functions include mysql_real_escape_string for database query handling, htmlentities to filter user input for HTML and two hashing functions to create hashes you can validate from - md5 and sha1.