13 articles PHP

PHP: Checking if a form was posted with “REQUEST_METHOD” server global

Something so simple, let's say even in a framework like Symfony which I use all the time you want to just check to see if the incoming request was initiated by an actual form post.  Here's the best way to check: I implement this switch in a lot of handlers where I deploy API…

General API interface with CURL: A simple way to access most APIs — use as is or extend as necessary

Since you likely interface with a lot of external APIs, there's no need to keep rewriting the same tool.  Just copy this and use the "apiBaseController" class as you need it.  It's a good, clean way to start any API accessing project!  

PHP Developers: Pre-made state pulldown lists for HTML forms

I like to reuse code as much as possible and if there's underyling data in something I'll use again, I'll put that data in some extractable form in an EAV (Entity, Attribute, Value) database table so I don't need to maintain the data anywhere except one place. So in the example below where the variable…

ZIP and password protect any file with simple script using PHP

"Rusty Padlock" artwork used with permission from ProlificFutility.com You may need to password protect a file before sending it to someone.  Yes, there are Windows utilities, some free, that do this but I found this script works surprisingly well as long as "zip" is installed on your server. Just simply save…

PHP cleaning strings with “preg_replace()” function and more resources for REGEX

Cleaning strings by removing anything that is not a letter or number can be very useful, like building clean URLs based on customer data. This will replace anything that isn’t a letter, number or space. Then, you can further clean the spaces by replacing with dashes ("-") for better URL readability. Note that "preg_replace"…