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 13. Web Automation

Introduction

Most of the time, PHP is part of a web server, sending content to browsers. Even when you run it from the command line, it usually performs a task and then prints some output. PHP can also be useful, however, playing the role of a web client, retrieving URLs and then operating on the content. Whereas Chapter 14 discusses retrieving URLs from within PHP, this chapter explores how to process the received content.

Recipes through help you manipulate those page contents. Marking Up a Web Page demonstrates how to mark up certain words in a page with blocks of color. This technique is useful for highlighting search terms, for example. Cleaning up HTML so it’s easier to parse and is standards compliant, is the topic of Cleaning Up Broken or Nonstandard HTML. Extracting Links from an HTML File provides a function to find all the links in a page. This is an essential building block for a web spider or a link checker. Converting between plain text and HTML is covered in Recipes and . Removing HTML and PHP Tags shows how to remove all HTML and PHP tags from a web page.

Recipes and discuss how PHP and JavaScript can work together. Responding to an Ajax Request explores using PHP to respond to requests made by JavaScript, in which you have to be concerned about caching and using alternate content types. Integrating with JavaScript provides a full-fledged example of PHP–JavaScript integration using the popular and powerful jQuery toolkit.

Two sample programs ...

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