Intended audience
This tutorial is intended for the PHP programmers who wish to use the output from other Web sites in their own scripts. A moderate understanding of PHP and HTML is assumed.
Overview
The example used in this tutorial is the automatic translation of phrases to multiple languages, to aid the development of multilingual applications.
When developing for the Internet, your audience will more than likely be from a variety of different countries and may not speak your language. You can easily adapt your own scripts to support multiple languages without speaking any of those languages yourself.
translate.dictionary.com is one of many Web sites offering translation services, and can be used within your own PHP scripts. Although the translations may not be perfect, they demonstrate the ability of your application to support multiple languages.
Objectives
In this tutorial you will learn how to:
- Read the output from third-party Web sites in your own scripts
- Send the correct information to Web sites to generate useful data
- Identify the output format and decide how to extract the data you require
- Utilize the data you have collected
Definitions
Target Web Page: The Web page from which data will be collected.
Background Information
This tutorial relies on the output from an external Web site. If and when the output from that site changes, modifications to any scripts that read information from the site may be required. If you are willing to spend a little time investigating how interactive Web sites work, the data they require and what they produce, you will often find that these sites produce useful data that you can use to enhance your own scripts.
Prerequisites
You may find it helpful to read the following sections of the PHP documentation:
How it works
First of all, visit the Web site http://translate.dictionary.com , where you will see the following form:
You need to find the data that this form collects to perform a translation. This particular page has a simple form and it is easy to pick out the elements you require. They are:
No comments:
Post a Comment