Entries tagged "DOMDocument"

Calculate Distance Between Zip Codes Part 2: Build the Search Engine

With a database full of zip codes, latitudes, and longitudes, you can get all the entries that are within a given radius using the Haversine formula…and a little help from Google. This week's post will build on the work done last time by developing a search engine where users can enter a zip code and a search radius. The script will then output all the records within the given radius. [Continue reading]

Calculate Distance Between Zip Codes Part 1: Geocode Database Entries with the Google Maps API

A few years back I looked into using the Google Maps API to calculate the distance between two zip codes. The proof of concept seemed to work well enough. But when I attempted to perform larger-scale calculations, the solution began falling apart. And it was slow… So I needed to develop an alternative solution. [Continue reading]

Check Your Error 404 Database for Broken Links with cURL

Some websites that I maintain have a database for tracking which pages have moved. The problem is that some of the links that indicate where a page has moved to break. So I end up with a 404 error saying a page has moved. When the visitor goes to the new page, they are greeted with another 404 error saying the page has moved. So let's look into writing a script to look through the database for broken links. [Continue reading]

Check for Broken Links with PHP Part 3: Targeted Search

Over the past few weeks we discussed a broken-link checker which leverages PHP's cURL library and DOMDocument. As the code stands, the script checks every link within a given page. That's great if we want to check every link, but what if we want to target a specific section of a page? Let's take a look at how this can be accomplished. [Continue reading]

Check for Broken Links with PHP Part 2: Capture Redirected Links

The link checker discussed previously was designed to report obviously broken links. There is, however, another type of broken link that isn't reported. When a web page is renamed or moved, a redirect may be created so visitors of the old page are automatically sent to the new location. To detect these types of broken links, we'll need to make a few minor modifications. [Continue reading]

Check for Broken Links with PHP Part 1

One aspect of managing a website that I want to streamline is the process of checking for broken links. Clicking on all of those links manually can be tedious. Especially if you have a page dedicated to posting external links. Now I know there are link-checking services available, but I've been looking for an excuse to experiment with cURL which is available through PHP. For those interested, I wanted to share what I have so far. [Continue reading]