damilola Posted June 11, 2013 Share Posted June 11, 2013 Pls after tring out the locale script in chapter 14. I encountered an error. Note am using wamp 2.2e which has php 5.4.3. This is the code: <?php header ('Content-Type: text/html; charset=UTF-8'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Locales</title> </head> <body style="font-size: 18pt;"> <?php # Script 14.5 - locales.php // Set the default timezone: date_default_timezone_set('UTC'); // Need a date object: $d = new DateTime(); // Create a list of locales: $locales = array('en_US', 'fr_FR', 'es_BO', 'zh_Hans_CN', 'ru_RU', 'el_GR', 'is_IS'); // Print the date in each locale: foreach ($locales as $locale) { // Set the locale: locale_set_default($locale); // Print the date: echo "<p>$locale: " . strtotitle(date_format_locale($d, 'l, j F Y')) . "</p>\n"; } ?> </body> </html> This is the error encountered: ( ! ) Fatal error: Call to undefined function locale_set_default() in C:\wamp\www\phpmyql3_scripts\ch14\locales.php on line 25 Call Stack # Time Memory Function Location 1 0.0021 142912 {main}( ) ..\locales.php:0 Pls help. Thanks. Link to comment Share on other sites More sharing options...
Larry Posted June 13, 2013 Share Posted June 13, 2013 This is a change in PHP since the book was written. Check this out: http://www.larryullman.com/2012/02/07/locale-aware-date-and-time-formatting-in-php-5-3/ Link to comment Share on other sites More sharing options...
damilola Posted June 14, 2013 Author Share Posted June 14, 2013 Thank you so much larry. Can u please and I say pls again, tell me why in chapter 14 (making universal sites) script 14.2 and upwards don't seem to be running as u said it would in the book. When I run the codes with my php 5.4.3 I get the result u said one would get if he ws running on php 5.2 or less. I already created a topic on dis (unicode) but did nt really get much understanding from what ppl said. Pls help me out have been stuck @ chpter 14 for the past one month now. Can wait to see ur reply sire. Thanks a lot. Link to comment Share on other sites More sharing options...
Larry Posted June 14, 2013 Share Posted June 14, 2013 Sorry for the inconvenience. THis book is 5 (or more) years old now, and a decent number of things have changed since then. Link to comment Share on other sites More sharing options...
Larry Posted June 14, 2013 Share Posted June 14, 2013 Always best to run the most current version of PHP you can, by the way. Let me know if you have any other questions or problems. Link to comment Share on other sites More sharing options...
Recommended Posts