On DevShed today, there's a new tutorial posted looking at two things that can cause headaches for PHP developers (especially when evaluating and comparing values) - nulls and empty strings.
Anyone who has programmed for any length of time has encountered the concepts of null and empty strings. They are not the same, and confusing the two can cause some serious problems. This article deals with these concepts in the context of PHP and MySQL.
They start with a bit of a quiz before getting into how to handle them correctly - making null "safe" and working with it correctly in a MySQL context. SQL statements and table structures are included for their examples.
The NETTUTS blog has this new tutorial posted (including a screencast) showing how to make a web application similar to the Address Book on Apple's OS X operating system.
As we all know, WordPress is so extensive that you can use it for nearly anything. There are even articles on sites with crazy titles such as 101 alternative uses for WordPress. So I thought, hey, why not? I bet a lot of people want to create their own Web Apps, and essentially WordPress can do that for you. In this video tutorial, we're going to make an online Address Book.
Building on a WordPress base and including jQuery and a Live Search Plugin, they create the multi-pane look and feel, styled largely with CSS. The end result shows your address groups, the members of that group and the selected member's information in the far right pane.
DevShed continues their series looking at user authentication in PHP applications with this third part of the nine part series. The focus is on the creation of the authentication scripts.
In this article we will continue to discuss the application-wide scripts that we started to talk about in the last article. These special scripts are used by all the scripts and pages of the application. We will continue to look at the func.inc script that has several useful functions defined in it.
Their func.inc script contains the helper functions the rest of the application can use (like isAdmin, isAuthd, genpass and checkEamil). They explain each of the the functions and include an example of them in action. The also include the other half of the pair - the logout script.
With the recent released of the 1.7 version of the Zend FrameworkRob Allen wanted to post about a new form element type that integrates some much needed functionality - Zen_Form_Element_File.
Now that Zend Framework 1.7 has been released, I thought I'd take a look at the built in file upload element, Zend_Form_Element_File, and see how it can be used. This is how to use it in its most basic form.
The form in this example is similar to his previous example and the simple code is included for the form, the controller and the view.
That's all there is to it for simple uploading of forms. There are still a few fairly important bugs in the component that we'll have to wait for 1.7.2 for. Specifically the Count validator doesn't always work as you'd expect and don't use getValues() and receive() as it isn't yet clever enough to know not to call move_uploaded_file() more than once.
As an introduction to the Datetime class functionality PHP 5 has, Kevin Watersonshows how to use it to calculate the "Friday the 13th" for any year.
This class is a request from a PHPRO.ORG regular who asked for a method to calculate Friday the 13th for the next n years. The calculation itself is easy, however, it presents a good opportunity to introduce the PHP datetime class.
He points out that timestamps, because of they way integers are handled, have a somewhat limited lifespan (2038) and dates beyond that cannot be determined by the usual date functions. Instead, he shows how to set up a DateTime object, set a timezone and loop through the days to find the Fridays that land on the 13th.
Stefan Mischook (of the KillerPHP.com site) has posted a new video tutorial about creating WordPress themes:
I just released a new video course on how to create a Wordpress theme/template from scratch. In these 12 videos, we will take someone with some beginner HTML and CSS skills through the steps needed to build a WordPress template from scratch. The videos use only a collection of freely downloadable tools that are available on Windows and Mac.
The full series will cost about $20 USD for a download or $30 USD to have the DVD shipped out to you. The videos focus on different parts of the process like making top-level navigation, setting up content areas and and creation of a custom homepage.
Chris Hartjes has posted his method for creating a development setup that lets you use multiple environments with your code.
In anticipation of my talk at PHP Quebec 2009 I've been going over my slides and thinking about what I'm going to update for it. One little nugget I'd thought I'd share is one way of handling having multiple environments your code must run in.
It uses a PHP variable in the $_SERVER superglobal - a custom one, APP_ENV - set by the application and checked to ensure global options are correctly set.
The NETTUTS.com site has posted the next part in their series on the creation of a photo site with PHP and jQuery. This time they focus on the backend of the application, written in PHP.
Chris Hartjes has started up a new series on his blog about converting legacy applications over to shiny, new CakePHP framework versions.
In my rapidly dwidling spare time I have been working on a project to convert an existing site for a legal services company over to PHP. I'm *this* close to being done, so I thought I'd share what I went through to get to where I am right now. [...] So after giving the code review I was asked to do the rewrite. The client realized that they had some serious maintenance issues on their hands and were in the process of creating a new look-and-feel for the site. Being the framework guy that I am, I indicated that porting the code over to a framework would be the best way to reduce maintenance issues going forward.
The series will document the process he followed to convert the application over. In part two he'll get into the meat of things - reworking the database structure.
The Zend Developer Zone has a new tutorial posted today from Vikram Vaswani about accessing a database with the help of the MDBTools PECL extension to read from a Microsoft Access datbase.
In this article, I'll introduce you to PHP's MDBTools extension, which provides an API to programmatically read data from Microsoft Access database files. If your project involves working with such files, extracting database records either for calculations or for conversion to other formats, you'll find this extension invaluable.
He steps through the installation of the extension (via the pecl command line tool) and some sample code that grabs the tables, all of their attributes and how to select the data out from them.