Category Archives: Php Freaks

PHP Closures as View Helpers: Lazy-Loading File Data

As an important part of PHP 5.3′s new features, closures have quickly made a mark on the language’s field. This is due to their versatile nature, which allows programmers to utilize them in a wide variety of use cases and situations. They not only yield great results when processing array...

Using PHP Closures as View Helpers

Unquestionably, the release of PHP 5.3.x, along with the imminent arrival of PHP 5.4 (at least, at the time of this writing), clearly show the level of maturity that the language has reached in the last few years. The inclusion of support for native namespaces, Late Static Binding, a largely...

Proem framework hits milestone 0.1.0

Phpfreaks admin Thorpe has been working on a new framework which has as its goal, use of the latest and greatest php 5.4 features. It’s important for the php community that people endeavor to explore these features if PHP is to continue to evolve and thrive. Proem has the goal...

Sanitizing Input with PHP

System-Level Program Execution Truly lazy programmers know how to make the most of their entire server environment when developing applications, which includes exploiting the functionality of the operating system, file system, installed program base, and programming languages whenever necessary. In this section, you’ll learn how PHP can interact with the...

PHP: Building Concrete Validators

Constructing purely static helper classes can hurt you, especially when you’re trying to build applications that adhere to the principles of good object-oriented programming. As I explained extensively in the first part of this tutorial, static helpers are inflexible structures that can only be extended via Inheritance, and that don’t...

PHP: Effects of Wrapping Code in Class Constructs

Let’s be honest: how many times have you found yourself writing a custom static helper class, or putting your hands eagerly on one that came bundled with a framework, from the many available out there? If you’re anything like me, the answer will be at least Â… a few (remember...

PHP File and Operating System Program Execution Functions

PHP’s Program Execution Functions This section introduces several functions (in addition to the backticks execution operator) used to execute system-level programs via a PHP script. Although at first glance they all appear to be operationally identical, each offers its own syntactical nuances. exec() string exec (string command [, array output...

PHP Proxy Patterns

There’s no doubt that the most challenging facet in the development of an MVC-based web application, even the simplest one, is the implementation of the model(s). While controllers and views are inherently relevant pieces within the pattern’s schema, they can be created to display a more relaxed behavior (at least...

PHP Proxy Patterns: Collections and Classes

Although they still haven’t gained the huge level of popularity of other design patterns (at least in the PHP field), proxies are a powerful paradigm that allows users to perform some clever tasks in OOP. These include unit testing classes, introspecting other objects, and even implementing more efficient data persistence...

PHP Proxy Patterns: Completing a Blog

While proxy objects can be utilized in a variety of situations and environments, they yield excellent results when lazy-loading data from an application’s persistence layer (usually this layer is seated upon a RDBMS, but it could be a web service or anything else). With the progressive adoption in the PHP...

Working with the File and Operating System with PHP

It’s quite rare to write an application that is entirely self-sufficient–that is, a program that does not rely on at least some level of interaction with external resources, such as the underlying file and operating system, and even other programming languages. The reason for this is simple: As languages, file...

PHP Tools for Working with the File and Operating System

File Types and Links Numerous functions are available for learning various details about files and links (or file pointers) found on a file system. Those functions are introduced in this section. filetype() string filetype (string filename) The filetype() function determines and returns the file type of filename. Eight values are...

Getting File System Data with PHP

Retrieving a Directory Size PHP doesn’t currently offer a standard function for retrieving the total size of a directory, a task more often required than retrieving total disk space (see disk_total_space()). And although you could make a system-level call to du using exec() or system() (both of which are introduced...

ArrayObject PHP Class: An Introduction

Added to PHP5 and improved in successive releases, the Standard PHP Library (SPL) is one of those things that, once you’ve used it, makes you wonder how you could live so long (and so painfully) without it. The library provides, right out the box, a set of native interfaces and...