Jump to content
Larry Ullman's Book Forums

Recommended Posts

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

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

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

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 14

Notice: Undefined variable: ma in D:\xampp\htdocs\Scripts\trans.php on line 21

Fatal error: Call to undefined function str_transliterate() in D:\xampp\htdocs\Scripts\trans.php on line 21

Link to comment
Share on other sites

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.

  • Upvote 1
Link to comment
Share on other sites

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

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.

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...