ITT #6: PHP Arrays as Return Values
In this installment of Instant Tip
Tuesday, we're going to talk about arrays in
PHP. According to the PHP manual, an array is "an ordered map that
associates values to keys." The benefit of using arrays is that we
can pack a ton of data into one variable, which means we can pass
that data back through a function.
What's So Cool About Passing Arrays?
I use arrays as return values to keep my processing of data
separate from the formatting of said data. This is done in an
effort to make code maintenance easier in the future. For example, look at
the following code:
<html>
<body>
<?php
require_once '_db/mysql.php'; // Connect to the database
$data = getDataFromDB("blog", 5); // returns latest 5 blog entries
...
read more
ITT #5: Transparent Overlay with Slide-Out Description
I'm going to try something a little different this week and talk about CSS.
I'm working on a client project that needed to overlay a PNG over the top
of various thumbnails in order to make the thumbnails sit in nicely with
the design. I'd never done anything like this before, so I thought it might
be worth sharing.
If you're deeply offended that I've strayed away from programming-related
posts, let me know in the comments, but don't worry! I added some jQuery in
for good measure!
View the Demo | Download the Files
The Markup
I'm a firm believer in using as few HTML elements and classes as possible.
I also really hate seeing empty elements that only exist to have styles
applied to them, so I try to make sure that every...
read more
FlickrScrollr Explained: jQuery
This is a continuation of the FlickrScrollr explanation. In
this post we'll explore the jQuery plugin behind the animation of the
thumbnails.
Why jQuery?
I resisted the switch to jQuery for a long time, telling myself that using
a JavaScript framework was some kind of copout—I was going to write
my JavaScript from scratch, dammit! And, for a long time, I did exactly
that. However, JavaScript is a finicky language, and it's supported
differently on each browser. Testing was cumbersome, exhausting, and
entirely too stressful. I felt like I was putting too much into the
relationship. I lost sleep, lost my appetite, and left long, slurred
messages on JavaScript's answering machine at 3AM.
"Hullo? Jahv-Scripp? I juss wann know: why you gotta make me use
element.style AND element.currentStyle? You wanna know why? Iss cuz...
read more
FlickrScrollr Explained: PHP
NOTE: Ok, so I totally rushed the
FlickrScrollr out the door on Tuesday in order to keep the Instant Tip
Tuesday series alive (because, let's face it, if I'd only made it three
weeks before I missed a Tuesday—well, I wouldn't be much of a blogger
at all, would I?). However, in doing so, I didn't really explain how the
plugin works or any of the advanced configurations of it. In an effort to
rectify that, I'm going to break the code down in this post.
The Goal of This Post
First, I'd like to readdress what FlickrScrollr is
and how it works, then I'd like to pick apart how the plugin was
built. Because this plugin uses both a PHP class and a jQuery
plugin, this writeup is going to...
read more