Prev | Current Page 672 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

This is the
subject of the next section.
?– Tip If your Web site offers material in a number of languages, perhaps the most efficient way to allow
a user to set a language is to store the locale string in a session variable, and then pass that variable into
setlocale() when each page is loaded. See Chapter 18 for more information about PHP??™s sessionhandling
capabilities.
Localizing Dates, Numbers, and Times
The setlocale() function introduced in the previous section can go far beyond facilitating
the localization of language; it can also affect how PHP renders dates, numbers,
and times. This is important because of the variety of ways in which this often crucial
data is represented among different countries. For example, suppose you are a United
States??“based organization providing an essential subscription-based service to a variety
of international corporations. When it is time to renew subscriptions, a special message
is displayed at the top of the browser that looks like this:
Your subscription ends on 3-4-2008. Renew soon to avoid service cancellation.
For the United States??“based users, this date means March 4, 2008. However, for
European users, this date is interpreted as April 3, 2008. The result could be that the
European users won??™t feel compelled to renew the service until the end of March, and
therefore will be quite surprised when they attempt to log in on March 5.


Pages:
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684