Page 16 of All Articles

Truncate string with ellipses with PHP

We previously discussed how to calculate the length of a string in PHP and I made mention that using that function is how you would go about truncating a string if it’s over a specific length. I also said that down the road I would discuss the topic at hand, […]

Staying motivated with streaks

I’m having one of those weeks where I zero motivation to sit down and write a blog post. Spent part of the week in Austin with the work fam. Haven’t even unpacked yet. Still getting back into the swing of being at home. In the middle of a major redesign […]

Get date for Easter in PHP

All the good things about Easter aside, it’s one of those holidays that’s a pain to get the date for. This is because the date of Easter is based on the lunar cycle and Spring Equinox (March 21st). The date of Easter on a given year could fall between March […]

Chat Personas

Going to make this brief since it’s Easter and I forgot to blog ahead of time this week. So I’ve recently been hanging out on a few Slack teams. One with the work crew, one with my small group of tech friends and a couple of “public” teams with local […]

Serializing and unserializing variables in PHP

Serialization in PHP is the act of converting a variable into a storable value. When I say storable, I mean being able to store the result in say, a database or a flat file. This is commonly applied to arrays and objects as they are not simply text strings. Under […]

Decouple your code from your web server

I used to be quite adamant about running nearly the same exact software stack locally as I did on my servers. Running Linux made it easy to pull this off and being able to do the same on OS X was a contingency for switching. I have never been a […]

Start your day with a list

I’ve been seeing these “how productive people start their day” posts on my social feeds a lot more recently. It got me thinking, “hey, I consider myself successful, how do I start my day?” A while back I started to make mental notes about how I started my day, or […]

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 as part of some server side user input validation or […]

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 post titled Features Are Complicated. This isn’t some dramatization, it’s […]

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 is a built-in function for getting the hostname: pre-5.3 $hostname […]

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 a new term that I’m on the verge of over […]

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 write the file’s contents back to disk: file_put_contents('./some/local/file', file_get_contents('')); Both […]

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 the last few years of blogging that my PHP blog […]

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 butt you can! First, you will need to interrogate the […]

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?” Rarely does that question get asked without a tone that […]

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 and it’s square root. Heck, you could even do it […]

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 blue'); The first argument is the string you want to […]

Developer titles are bullshit, Part 2 - Universal titles

Last week in part one, I discussed the lifecycle of a developer that just started a new job. The gist was that when someone starts a new role at a company, they generally have to learn the lay of the land. Regardless of their technical prowess there is always a […]

How to round numbers with PHP

Rounding numbers can be done a number of ways. You can round a float up or down to the nearest integer or you could round to a specific precision. Even then you can choose whether or not to round halves up or down and even round towards even and odd […]

Developer titles are bullshit, Part 1 - The lifecycle of a developer

This is a pretty universal truth, most developer titles are complete and utter nonsense. Shit like “Junior Developer” and “Senior Engineer Level 2”, sounds like we’re playing Dungeons and Dragons. Sad part of this is, most people will say they don’t care about titles but then they are quick to […]

Ikea Expedit standing desk

I wholeheartedly decided that I would convert my existing Ikea Expedit sitting desk and bookshelf combo to a “hipster developer” standing desk. Part of the decision was because of my buddy Mike. He was telling me about how using a standing desk had dramatically improved his posture and in the […]

Converting decimal to other number systems with PHP

It felt a bit like cheating to split this post up so I figured I would just cover all of the decimal to… functions in one post. Decimal, also known as base ten, is the numerical base we are most accustomed to. From time to time we need to convert […]

To infinity and beyond! Working with infinity in PHP

We can file this one under the “PHP functions I never knew existed and probably will never use” category. Seems that as of PHP 4.2.0 and beyond there was the inclusion of an is_finite() and an is_infinite() function. The names are pretty self explanatory and I’m sure there are some […]

5 things I learned by unliking all of my Facebook likes

In an effort to limit my digital footprint, one of the things I am doing is not liking every fucking thing on Facebook. In addition to not liking anything moving forward, I also went back and unliked everything that I have liked over the last 3 years or so. This […]

High Volume Showdown: Linode vs. DigitalOcean

I’ve done quite a few of these comparison posts and I have always stuck with the inexpensive plans. I figured, what the hell, let’s see how Linode and DigitalOcean stack up when running larger, comparably priced plans! The price point for this comparison is 640$ per month or around 96¢ […]