PHP Filter Functions

1 year ago

Late last year, I bookmarked a post on PHP filter functions. I've been using PHP for about 8 years and I've never heard of them. According to the PHP manual, the "filter extension is enabled by default as of PHP 5.2.0." Beforehand, it was an "experimental PECL extension," which might explain its mystery. If you're stuck with less than PHP 5, you're probably out of luck.

Technical details aside, the filters do what you'd expect: filter data. These filters could potentially replace most regular expression validation. Better yet, they provide a nice way to standardize this type of functionality. The workhorse function of this family is:

filter_var($value, $filter)

You simply pass it a variable and a predefined filter flag (or flags). Common filters provide validation of just about anything can you think of: email address, URL, string, integer, float, et al. The function returns a boolean FALSE if a value doesn't pass the filter.

In addition, the filters can also sanitize values. Those flags include sanitization for strings, quotes, special characters, et al. For starters, think of it as a replacement for cleaning GET/POST data with magic_quotes and/or mysql_real_escape_string.

The function that got me the most interested is the big brother to filter_var:

filter_var_array($data, $defintion)

Pass it an array of values, an array of filter definitions and it will give you back an array of results. With a little work upfront, you could streamline form validation with this function. I've got a validation class that I've been using for the past 2-3 years and I'm ready to rework it completely in favor of these filter functions.

I'll follow up this post with some impressions, once I get my hands dirty. However, I wanted to share this with anyone looking to step up their validation.

New Work, I'm Alive

1 year ago

December and January were both busy months, hence the lack of posts. Though, that's not much of an excuse. It's not like I can't spare 15 minutes, but I digress.

I've updated the Work page to include the new Dalek site I worked on with Nice Outfit, a site for Ramseur Records' folk-rock band Samantha Crain & the Midnight Shivers, a site for Jim Avett's gospel album and a little Google Maps API work on the York County Visitors Bureau website. I plan to discuss some of the nuts and bolts that went into these projects, but that's another post.

I've got a few more projects in the works and slew of blog posts in the tank. Time to breathe some life back into this blog.

Food For Thought #5

2 years ago

The more you say, the less people remember. The fewer the words, the greater the profit.

Google Analytics Tracking for Adobe Flash

2 years ago

This week at Adobe MAX, the Google Analytics team unveiled Google Analytics Tracking for Adobe Flash. According to Google:

This feature is a translation of the current Google Analytics tracking code into the ActionScript 3 programming language that dramatically simplifies the ability to track Flash, Flex and AS3 content. This new Flash tracking code provides all the rich features of the current JavaScript-based version, including campaign, pageview and event tracking and can be used to track Flash content such as embedded videos, branded microsites and distributed widgets, such as online games.

Developers have the choice of using a Flash Component or a AnalyticsLibrary Component, for complete control over tracking objects directly in AS3.

For more detailed information, check out the introduction and implementation guide over on Google Code. Then, watch the video demo on YouTube.

Augmented Reality

2 years ago

As this blog is essentially my soapbox to nerd out on web development, I'm occasionally torn about where to write about Flash. Since a handful of us in the Charlotte area are trying to get Flash Charlotte off the ground, I usually tend to post most of my Flash related news items there.

That said, I couldn't pass up the opportunity to mention the Augmented Reality project from Digital Pictures Interactive. You need to see it for yourself to really understand, but they've found a way to insert Papervision 3D objects into a webcam stream. If you have a webcam, you can try out the demo on their website.

Be sure to check out Flash Charlotte from time to time (especially if you work with Flash and live in the Charlotte, NC area). The group is still growing, but the blog is fairly active.

Food For Thought #4

2 years ago

It's easy to talk big about your big app. But you have to actually build it. You have to work every day. You have to sit in the chair and stay seated. And sleep and come back to the chair. You need to wear out that chair and then buy a new one and then wear out that one.

High-Quality YouTube Hack

2 years ago

Jimmy Ruska (via Kottke) discovered a nice query string hack to enable high-quality videos on YouTube. Basically, just append this to a YouTube video URL:

&fmt=18

According to Ruska, the format 18 video is encoded using "H.264 with stereo AAC sound at 480x360." Following the Kottke post, a YouTube engineer responded with a format 22 video, which is encoded at 720p. The engineer also noted that not all videos have format 18 or 22 versions, dependent on the source file uploaded.

MySpace Announces Profile 2.0

2 years ago

Ladies and gentlemen, the day has finally come—MySpace has launched a W3C standards compliant profile. Here's the official word from Tom himself:

The new profile is fully W3C compliant. It allows profile creators much more granular control by giving names to more objects. We still expect the third party layout market to flourish and will still allow users to use themes from layout sites.

I've yet to see it work, because I only have to music profiles and the new code is not yet available for those accounts. Though, it sounds like an answered prayer for anyone who has ever had to skin up a MySpace profile.

Not Another Sign-Up Form

2 years ago

I bookmarked a post on A List Apart earlier this year by the name of "Sign Up Forms Must Die." In the article, author Luke Wroblewski makes a great case for rethinking the placement and overall necessity for sign-up forms.

When planning a customer's initial experience for your web service, think about how you can avoid sign-up forms in favor of gradual engagement.

I've been brainstorming ways to skip the sign-up process for an upcoming project and I was reminded of said article. At the bottom of the page, Wroblewski provides a nice list of best practices to take away.

Food For Thought #3

2 years ago

I’m a big believer in launch fast, get feedback, make changes. We launched fast, got more feedback than we could handle, and failed to make changes. You can’t expect people to wait for you to get it right.

1 2 3 4 5 6