You are here: Blog » Code Snippets (Page 6)

Code Snippets

print_r pre

small_8484119632

When you are using a print_r in php, it’s a very good idea to remember the print_r pre combo (ie wrap the print_r in a pre tag). The difference being that using pre will allow you to understand the output as it will be preformatted in a way that is easy for humans to see…

Read More

Include Latest jQuery

jql

Here is a quick snippet which you can use to include the latest version of jQuery on your site.  Some benefits of this method: You’ll always be up to date Protocol isn’t defined so it’s safe to load from site’s starting with both http and https jQuery is served via a CDN so you don’t…

Read More

Copyright Current Year PHP

small_4371001458

One trick that I often use when building a site is to set the copyright year in the footer (or anywhere else you may want it) to always display the current year. This way, in the future you don’t have to worry about remembering to update it manually.   Here’s how to do it in…

Read More

Twitter API 1.1 Example

small_8476983849

In the footer of this website, I show my latest tweet. Until now I had been using Twitter API 1.0. Today Twitter stopped service for API 1.0 and I had to scramble to fix it so that it would work with Twitter API 1.1 (turns out it’s a lot more complicated). Here is the code…

Read More