Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Beginning PHP 5.3
|
BOOK: Beginning PHP 5.3
This is the forum to discuss the Wrox book Beginning PHP 5.3 by Matt Doyle; ISBN: 978-0-470-41396-8
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP 5.3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 27th, 2010, 07:27 AM
Registered User
 
Join Date: Sep 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default my this code is not running, where is the error plz define

< ?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 of “ . $diameter . “ < br / > ”;
echo “A circumference of “ . $circumference . “ < br / > ”;
echo “An area of “ . $area . “ < br / > ”;
? >
 
Old October 2nd, 2010, 03:42 PM
m0y m0y is offline
Registered User
 
Join Date: Apr 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to m0y
Smile

Hi, I'm learning PHP too and have a little trouble with this but i figured it out

1.- You have to save it as a .php file, .html doesn't work. (just in case)

2.- I supose you remove the first space on the br tag, like this
Code:
<br / >
or you can use old br tags
Code:
<br>
3.- You can use both syntax like this:
Code:
echo "This circle has... <br>";
or
Code:
echo "A circumference of " . $circumference . " <br / > ";
both work the same, at least on this example

Hope this can help you some and lets continue learning!!
 
Old December 25th, 2010, 09:35 PM
Registered User
 
Join Date: Dec 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I realize this is an old thread, but there were several syntax errors:

1. extra space between within <?php (spaces not allowed)
2. extra space between < and br on each echo line
3. extra space between / and > on each echo line
4. "smart" or "curly" quotes (“ and ”). You must use straight quotes "
5. extra space between ? and >

correct code is
Code:
<?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 of " . $diameter . "<br /> ";
echo "A circumference of " . $circumference . " <br /> ";
echo "An area of " . $area . " <br /> ";
?>
--Doug





Similar Threads
Thread Thread Starter Forum Replies Last Post
Plz help me with this code hhas Beginning VB 6 5 May 26th, 2010 08:45 AM
Error while running javascript code in ASP.NET Pag fozia_izhar ASP.NET 1.0 and 1.1 Professional 2 December 20th, 2006 03:39 AM
Plz Help Me Check What's Wrong Of This Code ! ck C++ Programming 1 January 13th, 2005 12:12 AM
Getting error message when running code. lilbit BOOK: Beginning Access VBA 1 July 31st, 2003 12:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.