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 […]

Refocusing my blog’s content

By Josh Sherman
3 min read
blogging
writing
retrospection

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

By Josh Sherman
1 min read
development
php
security

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

By Josh Sherman
5 min read
development
productivity
time management
inspiration

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

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