There are a lot of nice packages that we can use in our PHP-based projects and if you’re using Composer or GrumPHP, PHPCompatibility is one that I recommend including your projects especially if you’re writing code for something that’s going to run across multiple versions of PHP (that is, on hosts that offer different versions).
This is a set of sniffs for PHP CodeSniffer that checks for PHP cross-version compatibility. It will allow you to analyse your code for compatibility with higher and lower versions of PHP.
As I head into December of this year, this will be the final – and obviously the third – time I take off the social web for the remainder of the year. At least that’s the plan. I’m thinking of doing it a little bit differently this year.
For those of you who haven’t read about my doing this in years past, check out:
After two years after writing a lot of content and giving exclusive access to site members, this past weekend I opened the site to everyone.
But this wasn’t a small nor was it a quick decision and it’s not something that I opted to on a whim. For those who were subscribed to the newsletter earlier this year, I made an announcement that this was coming.
Anyway, all of the above is still about filtering variables. What about inputs, though? That is, those that come from $_POST or $_GET. It’s possible to use a similar strategy with a different function and different filter set.
But if you understand the basics presented in the last post, then this post will not be very different.
I’ve talked about data sanitization in WordPress in previous posts. This is a topic that’s important not only for those of us working to build solutions for others in WordPress, but also for those who are writing code that will directly interact with a database via PHP.
Sure, there are native WordPress functions to make this process easier, but there are also built-in PHP filtering functions to help with this. Namely filter_var and filter_input and these are things that I think are helpful for PHP developers to know.