Category Archives: PHP

Copying Images with allow_url_fopen Switched Off

I’m working on a Facebook app that needs to collect images from an external server. Normally I could use a function like copy to do this, but this requires allow_url_fopen to be on and a lot of providers like mine have this turned off to tighten server security.

Eventually I came across file_get_contents to do the job. Since this also needs allow_url_fopen to be on, my post on fetching page content with cURL came to mind.

This does the same thing without restrictions on privacy and is available on most current setups. Continue reading Copying Images with allow_url_fopen Switched Off


How to Send a URL Fragment Anchor to PHP

The URL fragment anchor (or accelerator, ID link or jump point) can be used to relocate the visitor to a specific part of a page. This is done by giving an element an ID then linking to it with a hash symbol (# or number/pound sign) like so:

http://example.com/page.php#content

The “content” part of this URL however never gets passed to PHP since it is only used client-side. However, with a little bit of help from JavaScript we can do exactly that. Continue reading How to Send a URL Fragment Anchor to PHP


Parsing the Kongregate Badge Feed with PHP

Back in September of last year, Jim Greer of Kongregate.com posted an article in the forums about a new badge data service served in JSON. This was great news for developers, we could finally grab data from our user accounts without having to do a web scrape on our user page.

However, this forum post seems to be the only official documentation on what is a very interesting data feed, so it is with this reason that I decided to create this beginner’s tutorial on how to use it. Continue reading Parsing the Kongregate Badge Feed with PHP


How to Fetch Page Content Using PHP

The web has so many useful services now, many offering their own API that you can draw data from and create your own mashups with. Websites like Twitter, Facebook, Flickr, and Kongregate are just a few.

Their data output is most commonly formatted in RSS (for feed readers), and JSON (a lighter form than XML used a lot for AJAX). In this post I’ll show you how to use the cURL library to collect data from any public web page. Continue reading How to Fetch Page Content Using PHP


The PHP Include

At the point that your site becomes more complex, you look to ways of simplifying your page code to give yourself less headaches. Ultimately you’re looking for a way to separate that header that you’ve copy-pasted so many times to different static web pages, into a page that all your other pages can call, and will stay the same.

If like me you hadn’t heard about PHP until this point where you are looking to add in other scripts to your web pages, then now is a very good time to learn about PHP includes.

1
< ?php include( 'header.html' ); ?>

Continue reading The PHP Include