Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Increase Productivity by Creating PHP Helper Functions
Jul 06, 2010 @ 09:20:57

On NETTUTS.com today there's a new tutorial talking about something many frameworks make pretty heavy use of - helper functions.

Every workman needs a good toolbox, and web developers are no different. PHP helper functions are designed to speed up and homogenise repetitive tasks, and make your life that much easier. This first tutorial explains how to make link helpers that will improve your methods for adding hyperlinks and mailto links in your web applications.

They give several examples of a helper function (with code) that starts as a simple link creation helper but progresses to allow styling, flexibility and even adding in the ability to use it to create mailto links.

tagged: tutorial helper function anchor mailto


PHP in Action:
Get links with XPath
Oct 07, 2008 @ 08:43:33

In response to this tutorial over on the PHPro.org website a new post has been made to the PHP in Action blog with an "even cooler" way to do the same sort of DOM fetching - XPath.

I'm a little bit surprised at the claim [the tutorial makes] that it's the "correct" (only) way, since there's at least one more that I find even cooler: XPath. Admittedly, it's slower, yet it's a more powerful language.

A quick example is included, building up from a simple search for anchor tags up to a custom query looking for just the anchor tags with a class of "bookmark".

tagged: xpath tutorial dom link find search anchor attribute