I’ve been fascinated over the last few days by sampulator, a great little project by @stevespaced that allows you to sequence...
Originally created by Rasmus Lerdorf in 1994, the PHP reference implementation is now produced by The PHP Group.
We will be looking at using cookies in PHP, not the cookie you enjoy eating, but the cookie as a tool for web development. We will examine what a cookie is, discuss how to create one, learn about how to delete and modify them. In web dev a cookie is a tool used to identify a user. A cookie is a small file that is embedded by the server on [...]Ashley
Sometimes we need to export and convert data from a database into a CSV format that can be downloaded and manipulated for other purposes. This function will loop through the multi dimensional array and convert the data to CSV format and output the download to the browser forcing the headers to download the file. The CodeAshley
PHP isn’t limited to just generating HTML. It can also be used to create and manipulate image files in a variety of formats. I recently worked on a project where we had to generate an image for the user and include their name flattened into it. It’s extremely easy to do with PHP. Admittedly the demo I’ve put together for [...]Ashley
This clever bit of code checks if a page has been modified since it was last displayed and if it hasn’t, it sends a “304 not modified” header and exits, otherwise the content is loads as normal. Add the code below to the top of each PHP page you want to apply it to. It’s especially useful if you serve static content [...]Ashley
Following on from yesterdays function to get likes and share data for a URL here’s a function to get Google Plus’s for any URL. The Code It’s worth pointing out you must have CURL enabled on your web server, I believe it’s enabled by default on PHP5 setups. Also the Key below Isn’t a unique API key you must leave [...]Ashley
We launched a new product at Harkable last week called Daily Pulse – which tracks social data for any URL, you can also subscribe to receive email reports. I thought i’d share a bit of functionality similar to how we engineer Daily Pulse. The Code Below is a super simple function that retrieves a JSON feed of comments, likes and [...]Ashley
Here’s a selection of really useful PHP code snippets that I find using on a weekly basis. You could use these as is or expand them as part of other applications or add them to a php class. Adjust server time If you have a server in a different timezone to you then you might be seeing funny things happen when you add the time to a MySQL [...]Ashley
Here’s a very simple solution to handling a variety of HTTP errors like 404, 500.. etc in one php file. All we need to do is create an array of error codes and match against them by picking up the global redirect status code using PHP. This means that we can use one page the handle multiple errors. The Code You’ll need to update [...]Ashley
Here’s a basic but useful snippet to either check that a website is online or domain exist. It’s a very simple function that uses CURL to check the response from a given URL. if a response is received we can assume that the site is up/online. The Code Display the responseAshley
I had a project recently that required the user to select their country from a drop down list and store the data in a database. It was such a long process setting up the PHP switch statement that I thought someone might find it useful for a project. The code below is a snapshot of the switch statement I’ve setup. The download at the [...]Ashley