Blog
Calculate the length of a string with PHP
Calculating the length of a string is a useful feature of any language, in fact it's one of the few pieces of functionality that has a consistently simple syntax across modern languages. You can calculate the length of a string [...]
Non-binary genders are complicated
No, this post is not some rant about non-binary genders. I'm actually referring to the trials and tribulations that I went through to implement a third gender option on my social network. The title is an homage to the CSS-Tricks [...]
How to get a server's hostname in PHP
The hostname of your server or local system is an easy way to determine which environment you are working with, either local or production. Prior to PHP 5.3 you would need to utilize the php_uname() function and with 5.3+ there [...]
Never stop learning
As cliché as this post's title is, I tend to forget this simple truth from time to time. This week was one of those weeks where I learned a ton of shit. Worked with some new to me libraries. Learned [...]
How to save a remote file to disk with PHP
You may already be familiar with file_get_contents() for reading the contents of a local file but did you know that you can use it to read the contents of a remote file or site? You can then use file_put_contents() to [...]
Refocusing my blog's content
For my first post as a 34-year-old, I wanted to announce that I am refocusing my blog's content. It's a pivot of sorts as I have been pining over what I should focus my content on. I have noticed over [...]
Basic HTTP Authentication with PHP
Basic HTTP Authentication is easily accomplished at the web server level (by way of .htaccess with Apache or inside your nginx configuration file) but did you know you could pull it off inside of a PHP script? You bet your [...]
Making time for side projects
I'm absolutely sick and tired of hearing people complain about not having any time for their side projects. Even worse is when I get asked the seemingly presumptive "how do you find for side projects when you have a family?" [...]
Life of Pi - Working with Pi in PHP
The irrational mathematical constant of Pi can be obtained a few different ways in PHP. There is a function to give you the value as well as a bunch of constants that represent Pi as well as fractions of Pi [...]
How to replace a string with a string in PHP
String replacements in PHP are very simple and as per usual, can be done in a variety of different ways. First let's take a look at the most simple form of a string replacement: str_replace('blue', 'red', 'My favorite color is [...]