PHP & MYSQL: THE MISSING MANUAL
XIV
WHAT IS
MYSQL?
JavaScript Is Loose, PHP Is…Less So
If you’ve written some JavaScript—and if you’re checking out this book, that’s prob-
ably the case—then you know that JavaScript lets you do just about anything you
want. You can occasionally leave out semicolons; you can use brackets, or not; you
can use the
var
keyword, or not. That sort of looseness is both great for getting
things working quickly, and at the same time, frustrating. It makes finding bugs tricky
at times, and working across browsers can be a nightmare.
PHP is not quite so loose as JavaScript, so it makes you learn a little more structure
and tighten up your understanding of what’s going on as your program is interpreted.
That’s a good thing, as it’ll end up making you tighten up your JavaScript skills, too.
And, perhaps best of all, PHP’s stodgy consistency makes it easier to learn. It gives
you firm rules to hang on to, rather than lots of “You can do this…or this…or this…”
So get ready. There’s lots to learn, but everything you learn gives you something
to build on. And PHP lets you know right away when there’s a problem. You won’t
need to pop open an Error Console or keep an eye out for Internet Explorer’s tiny
yellow warning triangle like you do with JavaScript.
PHP Is Interpreted
PHP code comes in the form of
scripts
, which are plain text files you write. The PHP
interpreter
is a piece of software on your web server that reads that file and makes
sense of it, giving the Web server HTML output and directions about where to go
next, or how to interpret a user’s form entry. Your text file is interpreted, one line at
a time, every time that file is accessed.
This scheme is dierent from languages like Java or C++, which are
compiled
. In
those languages, you write in text files, but then run a command that turns those
text files into something else: class files, binary files, pieces of unreadable code that
your computer uses.
The beauty of an interpreted language like PHP—and JavaScript, for that matter—is
that you write your code and go. You don’t need a bunch of tools or steps. You write
PHP. Test it out in the browser. Write some more. It’s fast, and that usually means
it’s pretty fun.
What Is MySQL?
MySQL is a database. It stores your information, your users’ information, and any-
thing else you want to stu into it. There’s actually a lot more nuance to MySQL—and
SQL, the language in which you’ll interact with MySQL (but better to save that for
Chapter 3—when you’ve got a little PHP and context under your belt).
For now, think of MySQL as a warehouse where you can store things to be looked
up later. Not only that, MySQL provides you a really fast little imp that runs around
finding all that stu you stuck in the warehouse whenever it’s needed. By the time
you’re through this this book, you’ll love that imp…er…MySQL. It’ll do work that you
could never do on your own, and it’ll do that work tirelessly and quickly.