The following snippet is a simple PHP Pagination Script which I wrote. As far as I know it works fine. It is meant to be used within a class, and I have wrapped in in a class in order to demonstrate it's usage.
The example given below will return something similar to the following:
When there are a sufficient number of pages present, a Last Page link is added. When you navigate away from the first page, a previous page link is added. When you navigate past the second page, a first page link is added.
This code hasn't been tested all that much. It has worked fine for me, but I have only used it in limited situations and only in development. If you have any problems, please let me know.