Articles

Zend Framework

Zend Framework is a PHP framework, written and maintained by Zend. It is designed to make development of web applications secure, streamlined and reliable.

Zend Framework

As with all frameworks there is a learning curve with Zend. However, as soon as you get over this it gets a lot easier. I found that the best way to understand how to program with the Zend Framework is to find some tutorials. Luckily, there are people out there who have created a few Zend tutorials.

Rob Allen has a nice Zend Framework Tutorial which is available at his site. Rob also has a nice tutorial on Zend Framework authentication.

Finding Out Where Users Have Come From In PHP

It is sometimes a good idea to find out where users can come from. When PHP is run the $_SERVER superglobal is always available and if the user has clicked on a link and landed on your page then the HTTP_REFERER value will be set. You can retrieve and view it on a test page like this.

if ( isset($_SERVER[ HTTP_REFERER ]) ) {
 echo $_SERVER['HTTP_REFERER'];
}

Of course you might want to do something useful with this. For example, you might want to know what link a user clicked on when they broke your application.

Some .htaccess Rules To Improve PHP Portability

PHP is a powerful tool, but if you create any piece of software there are one or two things that you should never rely on.

A good example is using PHP short tags. This is a short hand way of stating that this block are to be parsed as PHP. This is an example of a normal tag.

<?php echo 'Hello World'; >

Here is the same code using short tags.

<? echo 'Hello World'; >

Another alternative, if you just want to print the output of a variable, is to use the following.

<?='Hello World'; >

The short tags setting can be turned on or off in the php.ini file. If you create an application that relies on these short tags then you will find that on some systems the short tags setting is turned off, which means that your software will simply not work.

Nofollow Highlighting In Google Chrome

I found this excellent bookmarklet the other day which allows you to see nofollow links quickly and easily in Chrome most modern browsers.

Nofollow?

The bookmarklet consists of the following JavaScript.

Creating A Personalised Events List With SimplePie

One nice feature for any blog or site (especially news sites) is to have a little list of forthcoming events that would interest your readers. One way of collating this information is to scour the web and update the list manually. However, this is time consuming and tedious, especially as there is an easier way to do it.

Have a look at the Yahoo site called Upcoming. On this site you can search for events on lots of different subjects in lots of different locations all over the world. Also, if you have an event you can put it up on the site.

PHPNW 08 Conference

The PHPNW conference was this weekend, and 8 members of staff from my company showed up to support the PHP community and learn a couple of things along the way. The conference consisted of 174 attendees, with 12 sessions hosted by 16 speakers.

The talks ranged from simple usability and design to getting started in Drupal and they were all well researched, planned and executed. I was especially impressed with the 3D timeline used in the Twittex talk.

The two talks that stood out for me where the Introduction to the Zend Framework and HTML to Drupal in 30 minutes. I will definitely be looking into these two products, and perhaps even buying a book on the Zend Framework.

Drupal

Drupal is a CMS system that can be freely downloaded and used from the Drupal website. It is not an object orientated PHP driven system and so everything is available through function calls and variables.

Drupal

I have heard that the learning curve on developing Drupal is quite steep, but once you get around this initial hurdle the whole thing is pretty simple. This ease of development means that it is possible to take an idea and use Drupal and all its features as the CMS behind your idea, thus saving you time on your project development.

Converting UK PostCode To Longitude And Latitude With PHP

This common problem has stumped many programmers in the past, so I thought I would add in my little part. Whilst doing research for this I managed to find a site called www.streetmap.co.uk which has a nice little PostCode to geographical reference tool. Using a simple URL parameter I was able to give the site a PostCode and strip the longitude and latitude from the resulting HTML. Here is the function I came up with.

Enabling Image Formatting In Your Wordpress Template

One neat thing about Wordpress is the ability to add images to your posts in a quick and easy manner. You can also create thumbnails of larger images and link to them using a captioned image. The only problem is that when you have sorted out how your images look in your post in the admin section they just don't appear the same in your template once you have published it.

This is because Wordpress creates a set of styles that are used in the admin section and the default Wordpress templates. However, these styles are usually left out of custom template stylesheets. If you want to use the same sort of formatting that the Wordpress admin section has then open up your stylesheet file in your template and put the following stylesheet rules in at the bottom.

Preventing Accidental Moving Off Site With JavaScript

There is nothing more irritating than when you are typing out a long message in a text box and you accidentally move backwards, or clicking on a link and moving off page, therefore losing data you may have entered. There is a solution to stop this happening and it involves the onbeforeunload event.

Although not technically a fully supported event, onbeforeunload is run just before the page is unloaded out of cache. The onunload event occurs right after this, and it is too late by that point.

To prevent a user from moving out of the current page without some form of warning you will need to return some text with the onbeforeunload event. In some browsers that text will be used as part of the message, some browsers will ignore the message but continue anyway.

Include the following body tag in the page you want to incorporate this feature into.