332,98
Of course, it makes sense to render such information in a manner most familiar
to the user, in order to reduce any possibility of confusion. To do so, you can use
setlocale() in conjunction with number_format() and another function named
localeconv(), which returns numerical formatting information about a defined locale.
Used together, these functions can produce properly formatted numbers, like so:
600 CHAPTER 23 ?– B U ILDING WE B SITES FOR THE WORLD
setlocale(LC_ALL, 'it_IT');
$locale = localeconv();
printf("(it_IT) Total hours spent commuting %s
",
number_format(4532.23, 2, $locale['decimal_point'],
$locale['thousands_sep']));
setlocale(LC_ALL, 'en_US');
$locale = localeconv();
printf("(en_US) Total hours spent commuting %s",
number_format(4532.23, 2, $locale['decimal_point'],
$locale['thousands_sep']));
?>
This produces the following result:
(it_IT) Total hours spent commuting 4532,23
(en_US) Total hours spent commuting 4,532.23
Summary
Maintaining a global perspective when creating your Web sites can only serve to open up
your products and services to a much larger audience. Hopefully this chapter showed
you that the process is much less of a challenge than you previously thought.
The next chapter introduces you to one of today??™s hottest approaches in Web
development paradigms: frameworks. You??™ll put what you learn about this topic into
practice by creating a Web site using the Zend Framework.
Pages:
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686