Sie sind auf Seite 1von 4

according to your choices.

You can't build a web site like that using raw HTML, and that's where PHP4 comes in. So what sort of things can we do with it? Well, we can program sites that will: Present data from a wide variety of different sources, such as databases, or fil es Incorporate interactive elements, such as search facilities, message boards, and straw-polls Allow the user to perform actions, such as sending e-mail, or buying something In other words, PHP4 can be used to write the kind of web sites which anyone fam iliar with the Web uses every day. From e-commerce sites, to search engines, to information portals, most major web sites on the Internet incorporate some or all of these sorts of programming. In the course of this book, we'll be using it to build, among other things: A browser-based text editor, which lets us create and edit files on the web serv er from our web browser A web site for a shopping mall, which allows us to search for stores which sell a certain item, and displays the stores on a map An online word game A directory-based web search engine, which allows people to search all the web s ites in the directory, or find web sites by navigating through a hierarchical topic structur e A mailing-list service, which allows users to subscribe to different mailing lis ts, and allows the list administrators to then send out e-mails to the subscribers So, PHP4 can be used for a diverse range of applications, from utilities like th e text editor, to powerful web sites such as the shopping mall and directory examples. In this book, we're going to t ry and equip you with the necessary knowledge to build any kind of web site you want using PHP4. You'll learn some u seful coding techniques along the way, and we'll hopefully give you some ideas that you can incorporate into your own applications. Why PHP4? One of the best things about PHP4 is that it is supported by a large number of I nternet Service Providers (ISPs), which means that once you've written an application in PHP4, you can easily put it on the Web for anyone to use. You can find a list of ISPs who can help you with hosting PHP-based websites at The Prompt When we start looking at databases in Chapter 11, we'll be introducing the MySQL database manager, and making extensive use of its command line interface. If you're primarily using your comp uter in a 3 graphical environment like Windows or X, you may not be familiar with using the command line interface, or "shell". Before these graphical environments came into common use, users had to start a new program not by finding its icon and clicking on it, but by typing its name. The "shell" is the program that takes the name from you the "shell prompt" (or just "prompt") refers specifically to the text that prompts y ou to enter a new program name, and more generally to working with the shell instead of using a graphical interface.

Some people still find working with the shell much easier, and many sophisticated shells have been developed to simp lify common tasks. To get to a prompt in Windows, look for Command Prompt or DOS Prompt in the Star t Menu. UNIX users should look for a program called something like console, terminal, konsole, xter m, eterm, or kterm. You'll then usually be faced with a black screen with a small amount of text on it that says various things like: $ % C:\> # bash$ For the purposes of this book, however, we'll use a prompt that looks like this: > We'll show text for you to enter in bold, and the text the computer generates in a lighter typeface, like this: > mysqlshow +-----------+ | Databases | +-----------+ | mysql | | test | +-----------+ What Do I Need To Use This Book? We will be focusing on using PHP4 on Windows and UNIX platforms. As we shall see in the first chapter, we can install it on Windows 95 and 98, and NT and 2000. It will also run on virtually any flavor of UNIX, although our instructions only detail installation from RPM files. As well as the actual PHP4 libraries, you'll need a text editor to create and ed it your scripts. We'll look at a number of options in Chapter 1. You'll need a web server. Apache is a good bet on UNIX machines it's included in most Linux distributions, and you can obtain it from Windows users can also use Apache, or alternatively Microsoft's Personal Web Server (for 95 and 98) or Internet Information Server (for NT and 2 000). Chapter 1 explains how to get up and running. To get the most out of certain chapters, you'll need to have an Internet connect ion. However, don't panic if you haven't got one as long as you have the necessary software installed, you can ru n most of the examples in the book on a single machine, acting as both client and server. 4 PHP4 Resources Your first stop for information should be the official PHP site, which you can f ind at This not only features news, downloads, and complete documentation (including user feedback), but it also features a complete searchable index of all the above. PHP4 is based on the Zend scripting engine, owned by Zend Technologies, whose si te can be found at Here you'll find information specific to PHP4, as well as articles , case studies, and news about the different uses PHP4 is currently being put to in business environments. Another very useful resource is the site, a community-driven forum for PHP programmers.

It's a good place for useful tips and tutorials, and generally finding out what' s happening in the PHP programming community. Conventions We have used various styles of text and layout in the book to help differentiate between different kinds of information. Here are examples of the styles we use and an explanation of what t hey mean: Try It Out A 'Try It Out' Example 'Try It Out' is our way of presenting a practical example. How It Works Then the 'How It Works' section explains what's going on. Advice, hints and background information come in an indented, italicized font li ke this. Important bits of information that you shouldn't ignore come in boxes like this! Important Words are in a bold typeface. Words that appear on the screen in menus like the File or Window menu are in a s imilar font to that which you see on screen. Keys that you press on the keyboard, like Ctrl and Enter, are in italics. Code is presented in two formats. If it's a word that we're talking about in the text, for example, when discussing the fopen() function, it's in a distinctive font. If it's a block of code that you c an type in as a program and run, then it's shown in a gray box like this: $fp = fopen("./data.txt", "r"); 5 Sometimes you'll see code in a mixture of styles, like this: $fp = fopen("./data.txt", "r"); if(!$fp) die ("Cannot open the file"); This is meant to draw your attention to code that's new, or relevant to the surr ounding discussion (in the gray box), whilst showing it in the context of the code you've seen before (on the white ba ckground). Where we show text to be entered at a command prompt, this will be shown as foll ows: > mysqlshow Any output will be shown in the same font, only lighter: +-----------+ | Databases | +-----------+ | mysql | | test | +-----------+ Downloading the Source Code As you work through the examples in this book, you might decide that you prefer to type all the code in by hand. Many readers prefer this because it's a good way to get familiar with the coding techniques that are being used. Whether you want to type the code in or not, we have made all the source code fo r this book available at our web site, at the following address: If you're one of those readers who likes to type in the code, you can use our fi les to check the results you should be getting they should be your first stop if you think you might have typed in an e rror. If you're one of those readers who doesn't like typing, then downloading the source code from our web site is a must! Either way, it'll help you with updates and debugging.

Support & Errata One of the most irritating things about any programming book is when you find th at bit of code that you've just spent an hour typing out simply doesn't work. You check it a hundred times to see if y ou've set it up correctly and then you notice the spelling mistake in the variable name on the book page. Of course, yo u can blame the authors for not taking enough care and testing the code, the editors for not doing their job pro perly, or the proofreaders for not being eagle-eyed enough, but this doesn't get around the fact that mistakes do happen.