Learning PHP – Part 3: Variables
Gen. Jose Hernandez (from The Commons)
Well, somehow I managed to let more than a month slip by without getting this post up. Between being quite busy for a lot of the time, and a bit of procrastination it was easy to fall behind. I've been making progress off and on through PHP and MySQL for Dynamic Web Sites, but with the extremely hot weather in Toronto lately, it has been difficult to get any reading done on the subway sometimes.
Scalar Variables
Variables are the subject of this long delayed post. Variables are used in PHP in much the same way that they are in virtually any other major scripting or programming language. Variables use in PHP is fairly informal. A variable's name must start with a dollar sign and be followed with a letter or underscore (e.g. $variable); beyond that it can be called more or less whatever you want. Unlike in some other languages, variables can be created on the fly, and don't have to be declared or initialized beforehand.
A Quick Update On Things In General
Classing Sheep (from The Commons)
I've been putting off getting my next PHP post up for awhile now. Things just seem to keep getting in the way. At work I've been either out or working through my lunches, and at home I've been busy with budget stuff and Emily looking for a job among other things. Part of it is that I wasn't able to get access to all but the most standard ports for internet traffic at work, which stopped me from doing any MySQL stuff. Anyway, I've hardly forgotten about my project. I've had an opportunity to work on some PHP stuff at work for our website. So at least things haven't fallen completely by the wayside this last couple weeks.
I figured to keep the site active I'd put this post up, and talk about a variety of random stuff in it. One thing I'd like to talk about is the pictures I've been using for posts. Anyone who has been visiting my site regularly will have noticed the old-timey photos I've been using. These are all from The Commons, a repository of public realm photography housed on flickr. It's tons of fun to peruse if you've got a bit of time to kill. All sorts of interesting archival photography. I like switching between looking up photos of famous events in history and thinking up more obscure searches to see what comes up.
Learning PHP – Part 1: Getting Started
An Egyptian Bazaar (from The Commons)
Having finished off my HTML and CSS review and learning, I had a hard time deciding where to go next. Having already learned some JavaScript previously, I poked around in the W3schools tutorials for it, but ended up deciding to tackle PHP and MySQL.
Part of the reason I decided on PHP and MySQL is because I've had a book on the two technologies sitting around for some time. So I've been working my way through PHP and MySQL for Dynamic Web Sites (2nd Edition) by Larry Ullman. So far, in my humble opinion, it's an excellent book. I'm finding it is getting through the material at a good pace. The progression is quite logical from one chapter to the next, and the examples are quite relevant and useful. Since the book has been sitting around for awhile, it covers PHP 5 (which is now at version 5.3.6 a.k.a. PHP 6) and MySQL 4.1 (now at version 5.5). Obviously this makes it a bit out of date, but as far as I understand, the versions that I'm looking at are both still widely used, and the newer versions aren't a whole lot different.
Before jumping into the actual work I've done in learning PHP and MySQL, I figure I should give a bit of an introduction to what exactly PHP and MySQL are and what you do with them. The book also does this, which wasn't exactly that useful for me since I've got a fairly good undstanding of many web technologies, even if I don't know the details of how to actually use them.
Learning CSS – Part 8: Image Sprites and Media Types
Coolie on a road in Java, 1946 (from The Commons)
Glad to be doing this last CSS post. Like I've said before, I'm sure I'll be revisiting CSS after this, but not in an organized, step by step way. I've been through a good assortment of the basic stuff that can be done with CSS as well as a few more interesting aspects (like Sprites, coming up). There are all sorts of fancy CSS tricks, particularly with the new stuff in CSS3. Those are the kinds of things I'm looking forward to talking about in the future. For example, I read a neat post about advanced shapes you can make with CSS3 (I can't seem to find the link though).
Image Sprites
Back in the days before everyone was on broadband, you had to be super careful to keep your pages' file sizes small. Too many images and/or too long a page and the many users on 33.6-56k modems would be forced to sit through minutes of loading for every page. The issue still exists today, but it's now more of an advanced usability, SEO and high volume website concern.
When a page is loaded, the first aspect to be retrieved is the page's source code itself. In the source of the average webpage are calls to various external files such as JavaScript scripts, CSS files, and images. Each of these requires its own call to the server to download that file before the page can be displayed (generally at least, but not always). When you've got a handful of different external scripts, CSS files and a whole bunch of images to load, you're faced with quite a few separate requests to be made. These requests account for a significant portion of the load time for a page.
Learning CSS – Part 7: Navigation Bar and Image Opacity
Katoomba Falls (from The Commons)
I'm coming to the end of what was covered in the w3schools CSS Tutorial. As I mentioned in the last post about learning CSS, there are only a few more things I'd like to cover. In this post I'm going to cover the navigation bar example and image opacity parts of CSS Advanced.
CSS Navigation Bar Example
The CSS navigation bar example is a great way to show how CSS allows you to create quite visually appealing designs without the use of images. By combining a variety of different basic techniques that have previously been covered, quite a nice looking navigation bar is created. Instead of recreating it here, head over to the page using the link above and take a look for yourself.





Learning PHP – Part 2: The Basics
A papier-mache cow on Mrs Mellor’s car, 1944 (from The Commons)
Jumping into PHP hasn't been too hard for me. The book is aimed at people with a bit of programming/scripting experience, or at least a familiarity with the concepts. That worked just fine for me, since I have previously worked with VB a bunch when I was a teenager, and have had to hack bits of code here and there in the intervening years. So, the basics are more about learning the syntax and what sort of things you can and can't do.