Calculate the length of a string with PHP

By Josh Sherman
1 min read
development
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

By Josh Sherman
8 min read
scenekids
development
retrospection

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

By Josh Sherman
1 min read
development
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

By Josh Sherman
3 min read
career
autodidacticism
inspiration
motivation

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

By Josh Sherman
1 min read
development
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('http://phpave.com')); Both […]