p. This area is intended for everyone new to PHP. It opens with a series of informal, entertaining tutorials written by Vikram Vaswani, founder and CEO of Melonfire. These tutorials build on a previously-published 5-part series which has now been updated and extended to embrace PHP 5, making parts of it suitable for those of you who already have worked with PHP 4 in the past.
p. When you first started reading this series, I promised you that you’d have a whole lot of fun. If you’re the cynical type, you may be feeling that I didn’t keep my promise. After all, how much fun have you really had so far? All you’ve done is learn a bunch of theoretical rules, added and subtracted numbers from each other, learnt primitive decision-making and gone round and round in the circular funhouse of loops. Heck, if this wasn’t a PHP tutorial, it would be kindergarten…I hear you.
p. If you’ve been paying attention, you remember that in Part Two I gave you a quick crash course in PHP’s basic control structures and operators. I also showed you how PHP can be used to process the data entered into a Web form. In this tutorial, I’m going to delve deeper into PHP’s operators and control structures, showing you two new operators, an alternative to the if-else() family of conditional statements, and some of PHP’s more interesting loops.
p. After the workout I gave you last time, you’re probably either chomping at the bit to build another PHP application or you’ve decided to give up PHP programming and try growing cucumbers instead. If it’s the latter, you should stop reading right now, because I can guarantee you that this concluding installment of PHP 101 has absolutely nothing to teach you about vegetable farming.
p. Having spent lots of time travelling around the outer landscape of PHP – learning all about control structures, operators and variables – you’re probably bored. You might even be thinking of dropping out right now, and instead spending your time more constructively (or so you think) in front of the idiot box. That would be a big mistake. And when I say big, I mean humongous.
p. If you’ve been taking your regular dose of PHP 101, you know now enough about PHP to write simple programs of your own. However, these programs will be “procedural” or linear – the statements in them will be executed sequentially, one after another – simply because that’s the only programming style I’ve used so far.
p. You know what they say about a little knowledge being a dangerous thing… as your PHP scripts become more and more complex, it’s only a matter of time before you bump your head against the constraints of the procedural method, and begin looking for a more efficient way of structuring your PHP programs.
p. So now you know how to create your own functions in PHP, and you’ve spent the last few days busily inspecting your applications and turning repeated code fragments into functions. But functions are just the tip of the software abstraction iceberg. Lurking underneath is a three-letter acronym that strikes fear into the hearts of most newbie programmers.
p. One of the most compelling things PHP has going for it is its support for a variety of database management systems, including MySQL, PostgreSQL, Oracle and Microsoft Access. By virtue of this support, PHP developers can create sophisticated data-driven Web applications at a fraction of the time and cost required by competing alternatives. And nowhere is this more clear than in PHP’s longtime support of MySQL, the very fast, very reliable and very feature-rich open-source RDBMS.
p. If you’ve been paying attention, you now know how to use PHP’s MySQL API to perform queries and process result sets. You might even have started thinking about how to re-program your site to run off a MySQL database. All of this is a Good Thing – it means you’re getting comfortable with using PHP’s database support to power your applications – but there’s still a little further to go.
p. Now that you’ve used PHP with MySQL and SQLite, you probably think you know everything you need to get started with PHP programming. In fact, you might even be thinking of cutting down your visits to Zend.com altogether, giving up this series for something flashier and cooler…
p. PHP 101 (part 10): A Session In The Cookie JarUh-uh. Big mistake.