PHP Web Fundamentals
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. 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.shows the details of constructing a URL that includes a query string, including proper encoding of special characters and handling of HTML entities. Similarly, 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 lets you protect your web pages with passwords. PHP’s special features for dealing with HTTP Basic authentication are explained. It’s often a better idea to roll your own authentication method using cookies.
Cookies and Authentication are two specific HTTP headers. Learn how to read any HTTP header.Setting the HTTP status code is covered shows how to redirect users to a different web page than the one they requested.
The three following recipes deal with output control. shows how to force output to be sent to the browser. Explains the output buffering functions.Output buffers enable you to capture output that would otherwise be printed or delay output until an entire page is processed. Automatic compression of output.
The next two recipes show how to interact with external variables: environment variables and PHP configuration settings. Discuss environment variables. If Apache is your web server, you can use the techniques to communicate with other Apache modules from within your PHP programs.Identifying mobile browsers, so you can choose to provide alternative versions of your site.
This chapter also includes three programs that demonstrate some of the concepts. validates user accounts by sending an email message with a customized link to each new user. If the user doesn’t visit the link within a week of receiving the message, the account is deleted. A small example of a wiki system that makes any page on your website editable from within the web browser. shows how to parse the HTTP Range header to return specified portions of a file. This allows a client to resume an interrupted download exactly where they got cut off.
No comments:
Post a Comment