Skip to Content
PHP Cookbook, 3rd Edition
book

PHP Cookbook, 3rd Edition

by David Sklar, Adam Trachtenberg
July 2014
Intermediate to advanced
820 pages
17h 6m
English
O'Reilly Media, Inc.
Content preview from PHP Cookbook, 3rd Edition

Chapter 8. Web Fundamentals

Introduction

Web programming is probably why you’re reading this book. It’s why the first version of PHP was written and what continues to make it so popular today. With PHP, it’s easy to write dynamic web programs that do almost anything. Other chapters cover various PHP capabilities, such as web services, regular expressions, database access, and file I/O. These capabilities are all part of web programming, but this chapter focuses on key web-specific concepts and organizational topics that will make your web programming stronger.

HTTP requests aren’t “stateful”; each request isn’t connected to a previous one. A cookie, however, can link different requests by the same user. This makes it easier to build features such as shopping carts or to keep track of a user’s search history. Recipes , , and show how to set, read, and delete cookies. A cookie is a small text string that the server instructs the browser to send along with requests the browser makes.

Other good ways to pass data are through query strings and the body of the request. Building a Query String shows the details of constructing a URL that includes a query string, including proper encoding of special characters and handling of HTML entities. Similarly, Reading the POST Request Body provides information on reading the data submitted in the body of a request when it’s not form data, so PHP cannot automatically parse it into $_POST.

The next recipes demonstrate how to use authentication, which ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PHP Cookbook, 2nd Edition

PHP Cookbook, 2nd Edition

Adam Trachtenberg, David Sklar
Programming PHP, 4th Edition

Programming PHP, 4th Edition

Kevin Tatroe, Peter MacIntyre
MySQL Cookbook, 4th Edition

MySQL Cookbook, 4th Edition

Sveta Smirnova, Alkin Tezuysal

Publisher Resources

ISBN: 9781449363741Errata