Pages

Sunday, May 12, 2013

PHP: What, Why, and Where?

PHP is ultimately text, taken by your web server and turned into a set of commands
and information for your web browser. And because you’re just working in text,
there’s not a lot you have to do to get going as a PHP programmer. You need to
get familiar with PHP itself—and the best way to do that is to install PHP on your own
computer, even though most of your programs will run on a web server.
Then, you need to run an actual script. Don’t worry; it’s amazingly easy to write your
first program in PHP, and you’ll end up writing more than just one program before
you hit Chapter 2.
And through it all? You’ll begin taking control. PHP gives you the ability to be an
active participant in your web pages. It lets you listen carefully to your users and
say something back. So get going; no reason to leave you users with passive HTML
pages any longer.

Gathering Your Tools: You’ll need to take just a few steps before you can start with PHP. You can’t build a
website without a web browser, and you can’t write PHP without a few tools. But it
won’t take long before you’ve got your computer set up with your own customized
PHP programming environment.
Although PHP isn’t pre-loaded on every computer like web browsers are, you can
easily download PHP from the Internet, get it working on your computer, and get up
and running fast…all without spending a dime. On top of that, most of the easiestand best tools for writing PHP code are also free. All you need is your own copy of
the PHP language on your computer, plus a plain old text editor. This section shows
you where to find them.


PHP on the PC: PCs come with a lot of software pre-installed. Unfortunately, one program that most
PCs don’t come with is PHP. That’s okay though: you can get PHP up and running
in just a few minutes, as long as you have an Internet connection.
Note If.Open up your favorite Web browser and head to www.php.net. This site is PHP’s
online home, and it’s where you’ll download your own version of the PHP language,
along with all the tools you need to write and run PHP programs. Look along the
right side of the PHP home page for the Stable Releases heading; you can see it on
the right of Figure 1-1.

Figure 1-1

Once you’ve chosen a PHP version link, you’ll see a screen like Figure 1-2, with links
for the current version of PHP as well as at least one older version (which will have
a lower version number than the most current version).
Before you download PHP, though, take a look further down the page. There’s
a heading titled Windows Binaries, and that’s your ticket to getting PHP up and
running fast on your Windows machine. Clicking this link takes you to another site,
http://windows.php.net/download, which should look something like Figure 1-3.


 Take Control of Your PHP Installation
Like most of the programs on your computer, the PHP software
package (which includes the php program you’ve been running)
is updated fairly often. Most of the time, if you’re keeping
your computer updated with Apple’s Software Update, you
don’t have to worry about updating PHP separately. But if you
want to see what version of PHP you’re actually running, you
can type php –version into your Terminal window. You’ll get
back something like this:
Bretts-MacBook-Pro:~ bdm0509$ php -version
PHP 5.3.4 (cli) (built: Dec 15 2010
12:15:07)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-
2010 Zend Technologies
Look at the very first line that PHP spits out; it tells you you’re
running version 5.3.4. (See the box on page 5 for more detail
on how version numbers work.)
If you want to get the very latest version of PHP, you can visit
www.php.net and download the PHP source code. That’s a
little trickier than just using the version preinstalled on your
Mac, though, so unless you’re really into commands like unzip
and tar, you can stick with what’s already on your machine.
By the way, if you’re not using your Mac’s Software Update
frequently, you may want to do so now. It’ll keep your software
current, without all the hassle of downloading programs on
your own. Just choose •➝Software Update to find and install
new software that’s available for your Mac. And if your software
is up to date, the dialog box lets you know.

No comments:

Post a Comment