The PHP Security Guide discusses and explains in depth PHP security issues, including many code examples:

If you do not design your application with security in mind, you are doomed to be constantly addressing new security vulnerabilities. Careful programming cannot make up for a poor design.

Even a little security philosophy in there. Definitely worth bookmarking.