Jump to content

Wrox PHP book programs will not run


larka06

Recommended Posts

I have been studing php using a book named Wrox PHP.  So far I have had alot of trouble getting the code to work. I have had to us work arounds to get the results I am suppose to get. Here is the code the way it is in the book:

" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Circle Properties</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8"/>
<meta http-equiv="content-style-type" content="text/css"/>
<link href="common.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<?php
$radius = 4;

$diameter = $radius * 2;
$circumference = M_PI * $diameter;
$area = M_PI * pow($radius, 2);

echo "This circle has...<br />";
echo "A radius of " . $radius . "<br />";
echo "A diameter " . $diameter . "<br />";
echo "A circumference of " . $circumference . "<br />";
echo "An area of " . $area . "<br />";

<div class="logos">
    <p><a href="http://httpd.apache.org/"><img src="/icons/apache_pb2.gif" alt="[ Powered by Apache ]"/></a>
   
</div>
</body>
</html>
 

 

 

Here is what works:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd$

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title>Circle Properties</title>

<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>

<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8"/>

<meta http-equiv="content-style-type" content="text/css"/>

<link href="common.css" rel="stylesheet" type="text/css"/>

</head>

<body>

<?php

$radius = 4;

$diameter = $radius * 2;

$circumference = M_PI * $diameter;

$area = M_PI * pow( $radius, 2);

echo "This circle has...<br />";

echo "A radius of "; echo $radius;

echo "<br /> A diameter of "; echo $diameter;

echo "<br /> A circumference of "; echo $circumference;

echo "<br /> An area of "; echo $area;

?>

 

<p><a href="http://httpd.apache.org/"><img src="/icons/apache_pb2.gif" alt="[ Powered by Apache ]"/></a>

 

</body>

</html>

 

Does the book version look ok to anyone else? What is wrong? Should I abandon the book and get a better one some one knows about?

Link to comment
https://forums.phpfreaks.com/topic/281151-wrox-php-book-programs-will-not-run/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.