briansgl Posted February 25, 2014 Share Posted February 25, 2014 Sorry I originally put this question in the wrong place. I'm a little confused. I am ploughing my way through the book and now I'm stuck on this page. The question is probably stupid but here goes. How do I get this: <li>internationalization</li> To This? <li>Iñtërnâtiônàlizætiøn</li> I have an English keyboard. and Dreamweaver 5.5. All the settings in Dreamweaver seem to be right. I will copy my full script below. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.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>Testing UTF-8</title> </head> <body style="font-size: 18pt;"> <!-- Script 14.1 - utf8.html --> <p>Testing UTF-8 encoding. Here are some random words and characters: <ul> <li>internationalization</li> <li>€</li> <li>a</li> <li>b</li> <li>c</li> <li>d</li> <li>e</li> <li>f</li> </ul> </p> </body> </html> Link to comment Share on other sites More sharing options...
Antonio Conte Posted February 26, 2014 Share Posted February 26, 2014 The full script? This is just HTML code. Do you mean that this is the result after running the script, or are you missing all the PHP code? If this is your full script, the translation cannot happen automatically. You must add the PHP code to your script. Link to comment Share on other sites More sharing options...
briansgl Posted February 26, 2014 Author Share Posted February 26, 2014 I'm just at script 14.1 in Larrys book. If you download the script from Larry's site its in the right language. This is the result if I run it on localhost. Below is how the script looks in Larry's book. Sorry if it sounds a bit silly , I'm new to this and it's the first script that's confusing me. <!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>Testing UTF-8</title> </head> <body style="font-size: 18pt;"> <!-- Script 14.1 - utf8.html --> <p>Testing UTF-8 encoding. Here are some random words and characters: <ul> <li>Iñtërnâtiônàlizætiøn</li> <li>€</li> <li>ə</li> <li>∞</li> <li>ӈ</li> <li>ځ</li> <li>ש</li> <li>ᄳ</li> </ul> </p> </body> </html> Link to comment Share on other sites More sharing options...
Antonio Conte Posted February 26, 2014 Share Posted February 26, 2014 No question is stupid. Everyone has to start out somewhere. The script is actually just for testing your encoding. If you can see 'Iñtërnâtiônàlizætiøn', that means your encoding is correct. If you used an older encoding - like ANSI - you would see weird characters instead of the text. The encoding basically represents your "alphabet" and characters to use. The old ANSI does not support the characters in that text. That's the whole point, really. Does that make sense? Link to comment Share on other sites More sharing options...
briansgl Posted February 26, 2014 Author Share Posted February 26, 2014 I think so. It will probably make sense when I move onto the PHP script in this section. As I say I'm new to this but so far all the book seems to make sense and this is the first one I've got stuck on. Thanks for the help Antonio. Link to comment Share on other sites More sharing options...
briansgl Posted February 26, 2014 Author Share Posted February 26, 2014 Sorry to bother you again but I have done the script as per 14.2 as below: <?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>Translation</title> </head> <body style="font-size: 18pt;"> <em>Whats my name?</em> <?php // Your Name: $me - 'Larry Ullman'; // Create the array of scripts: $scripts = array('Greek', 'Cyrillic', 'Hebrew', 'Arabic', 'Hangul'); // Loop through each script foreach ($scripts as $script) { echo "<p>$ma is " . str_transliterate($me, 'Latin', $script) . "in $script.</p>\n"; } ?> </body> </html> And this was the result: Whats my name? Notice: Undefined variable: me in D:\xampp\htdocs\Scripts\trans.php on line 14Notice: Undefined variable: ma in D:\xampp\htdocs\Scripts\trans.php on line 21Fatal error: Call to undefined function str_transliterate() in D:\xampp\htdocs\Scripts\trans.php on line 21 Link to comment Share on other sites More sharing options...
HartleySan Posted February 26, 2014 Share Posted February 26, 2014 The first error is because you wrote $me -, but you need to write $me =. The second error is because you are using a variable called $ma, which is not defined. Did you mean to use $me here instead? The third error is occurring because the function str_transliterate is not defined. You need to add the actual code for that function somewhere in the script. 1 Link to comment Share on other sites More sharing options...
briansgl Posted February 26, 2014 Author Share Posted February 26, 2014 Thanks i noticed those errors and corrected them. I will re-post the script and also the error I'm getting now.. Not to sure what you mean by: "You need to add the actual code for that function somewhere in the script".I'm just following the scripts in Larry's book and its script 14.4 trans.php <?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>Transliteration</title> </head> <body style="font-size: 18pt;"> <em>What's my name?</em> <?php # Script 14.4 - trans.php // Your name: $me = 'Larry Ullman'; // Create an array of scripts: $scripts = array('Greek', 'Cyrillic', 'Hebrew', 'Arabic', 'Hangul'); // Loop through each script: foreach ($scripts as $script) { echo "<p>$me is " . str_transliterate($me, 'Latin', $script) . " in $script.</p>\n"; } ?> </body> </html> What's my name? Fatal error: Call to undefined function str_transliterate() in D:\xampp\htdocs\Scripts\trans1.php on line 21 Link to comment Share on other sites More sharing options...
briansgl Posted February 26, 2014 Author Share Posted February 26, 2014 I have just been looking round the web for a solution to my problem and it appears there is a mistake in Larry's book (Chapter 14). Larry has posted an amendment to one of the scripts here: http://www.larryullman.com/2012/02/01/transliteration-in-php-5-4/ Does this mean that all the scripts contained within chapter 14 are wrong? Link to comment Share on other sites More sharing options...
HartleySan Posted February 27, 2014 Share Posted February 27, 2014 It's a mistake in that he published the book with a function that he assumed would exist in PHP, but because PHP 6 never happened, it doesn't exist. As such, you need to follow the instructions in the page you linked to to get that to work. Certainly, that is confusing, but as a general rule, unless a function is defined in PHP or you defined the function yourself, then you will get the error you are getting. 1 Link to comment Share on other sites More sharing options...
Recommended Posts