echo() can interpolate a variable, but not an expression such as
"$this->Unitprice*2"

replace:
 echo " price * two is $this->Unitprice*2<BR>";

by:
$bytwo = $this->Unitprice*2 ;
 echo " price * two is $bytwo<BR>";

HTH
Ignatius
_________________________
----- Original Message -----
From: "Mark Harrington" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 03, 2003 4:54 PM
Subject: [PHP-WIN] Cant get maths functions to work in class file


> I have designed a class that multiplies one of the varibles by two but
when
> i pass the values to the contructor i cant get the answer out any ideas
>
> Here is the full script "If you can recognise the problem can you explain
> why its wrong and why its not working "Ps learning the langauge "
>
> The Class File
>
> class purchase {
>
> var $PartNumber;
> var $Description;
> var $Unitprice ;
>
>
>    // this is the constuctor
>
>  function purchase($partnumber,$desc,$price)
>  {
>   $this->PartNumber = $partnumber;
>   $this->Description =$desc;
>   $this->Unitprice =$price;
>    echo "Object created partNumber = $this->PartNumber <br>";
>  echo " This Objects Description = $this->Description <br>";
>  echo " This Objects Price is $this->Unitprice <BR>";
> //this doesnt work why ??
>  echo " price * two is $this->Unitprice*2<BR>";
>  }// end constructor
>
>
> }
>
>
> $myObject = new purchase(1,"Speaker",23.00);
>
> ?>
>
>
> [EMAIL PROTECTED]
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to