News Feed
Sections




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

DevShed:
Using Static Methods to Validate Data with Helpers in PHP 5
September 09, 2009 @ 08:29:55

DevShed finishes off their series on data validation with this eighth part - a look at using static methods to create a simple validation helper class (a rework of earlier code).

The methods of the [previously created] helper were always called in the object scope, implying that there was a previous instantiation of the class. In this particular case, this process is completely unnecessary, aside from encouraging a bad programming habit. Therefore, in this last tutorial of the series I'm going to improve the source code of this validation helper class by declaring all of its implemented methods static.

In the code they redefine their methods (like validate_int and validate_alpha) to be static and directly callable without having to make an instance/object of the class.

0 comments voice your opinion now!
static method tutorial validate


blog comments powered by Disqus

Similar Posts

PHPFreaks.com: Basic Pagination

PHPMac.com: Building and Installing Apache 2.2.2 and PHP 5.1.3 (or 5.1.4) on Mac OS X 10.4.6

NetTuts.com: Setting Up User Authentication in Laravel Using Confide

PHPBuilder.com: An Introduction to Graphs Using PEAR\'s Image_Graph Package

Gonzalo Ayuso: Releasing unmanaged resources (a PHP port from C#’s “using” statement)


Community Events





Don't see your event here?
Let us know!


package composer library security introduction install voicesoftheelephpant symfony opinion podcast language framework community release laravel version series interview tool application

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework