Suhosin is a project mainly written in C and PHP, it's free.
Stefan Esser's php extension for hardening the php core
http://www.hardened-php.net/suhosin/index.html