Jump to content

Wrox PHP book programs will not run


Go to solution Solved by 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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.