 | News Feed |
Sections
Community Events
|
| feed this: |  |
Ibuildings Blog: Accessing object properties by reference
posted Monday May 05, 2008 @ 14:38:49
voice your opinion now!
BY CHRIS CORNUTT
On the Ibuildings blog today, Harrie Verveer has posted about an interesting quirk he found when working with objects and references:
PHP is a loosely typed language. Most of the time this is very useful because you as a programmer don't have to worry about typecasting: it's done for you. However, on some occasions this can cause some unexpected trouble. [...] In this blog I want to point out what can happen if you try to access object properties by reference when the object is not initialized.
His example shows the problem when it tries to grab a value from an array in a non-existent object by reference. It results in a dyanamically created object (of that type) with an empty array inside of it. It only works when you grab it by reference, but he shares a tip or two about how you can prevent hard to track down issues like this.
tagged with: property object reference find difficult issue
Developer Tutorials Blog: PHP array_walk() Run an array through a function
posted Wednesday April 23, 2008 @ 08:47:09
voice your opinion now!
BY CHRIS CORNUTT
The Developer Tutorials blog has a quick example of how to use the array_walk function to maneuver through the array of your choosing and applying a callback method to each of its elements.
It’s a common sight: taking an array and running (well, walking) its elements through a particular function. Luckily, PHP provides a simple yet powerful function to overcome this: array_walk().
They include an example, giving a sample "some_function" the array_walk method uses when it's called, replacing a foreach (or other type of loop). Plus you can specify an object with the callback to run it against a method inside a class too.
tagged with: arraywalk function callback object method loop tutorial
PHPBuilder.com: PHP Form Validation System An Object-Oriented Approach
posted Monday April 21, 2008 @ 08:49:24
voice your opinion now!
BY CHRIS CORNUTT
Mike Weiner has put together an article for PHPBuilder.com that's posted today showing a bit more object-oriented solution to validating the user submitted data in your forms:
Whether it is for database submission, emailing, or for some other purpose, forms represent the primary means of enabling a user to send data to an application. As a result, it is important to have control over the data collected by your forms, which will aid in the creation of streamlined, error-free applications.
He lays out the validation method in a graphic going with a generic validation class that then calls the various validation methods (like phone or email) as needed. The "validation set" manages which validations are to be run on which form elements. Example code for each of the bits making up the structure and the implementation are provided.
tagged with: object oriented approach form validation tutorial
DevShed: Developing a Modular Class For a PHP File Uploader
posted Wednesday April 16, 2008 @ 13:28:49
voice your opinion now!
BY CHRIS CORNUTT
DevShed has posted the final part of their series looking at the handling of file uploads in PHP5. This last installment shows how to take what yuou've learned so far and make things a bit more modular.
At this stage, you've hopefully recalled how to build an expandable file uploading application with PHP 5 that uses only one custom function to transfer a target file from a client machine to a predefined web server. However, in the beginning, I said that I was going to teach you how to develop a brand new file uploading application using an object-oriented approach.
The finish off the FileUploader class they were working on previously and show some testing examples of it in action.
tagged with: modular object file upload handler tutorial
Michael Girouard's Blog: Rolling Your Own MVC The Page Load Scenario
posted Wednesday April 09, 2008 @ 15:33:45
voice your opinion now!
BY CHRIS CORNUTT
Michael Girouard has posted his 10,00 foot view of the typical structure of an Model/View/Controller application (and framework) and how a page request is handled:
In my previous article, I announced that I would be documenting the process of developing a simple MVC framework. In this post I will go into a little more detail about each of the specific components of our MVC and will discuss the series of events which occur each time a page loads, otherwise known as the page load scenario.
He talks about how URIs work, the role of mod_rewrite, several of the objects involved (like the Front Controller, Request, Route and View) and how they all fit in with the custom Models, Views and Controllers the user could define.
tagged with: modelviewcontroller mvc page load object route request
|