larka06 Posted August 14, 2013 Share Posted August 14, 2013 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 More sharing options...
kicken Posted August 14, 2013 Share Posted August 14, 2013 You're missing the closing PHP tag (?>) at in the first code sample. Other than that, it is fine. In the future when you post code please surround it in [code ][/code] tags. Link to comment https://forums.phpfreaks.com/topic/281151-wrox-php-book-programs-will-not-run/#findComment-1444950 Share on other sites More sharing options...
larka06 Posted August 14, 2013 Author Share Posted August 14, 2013 Thank you. I was sure it was something simple. Link to comment https://forums.phpfreaks.com/topic/281151-wrox-php-book-programs-will-not-run/#findComment-1445037 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.