Re: Cant get maths functions to work in class file
| From: | Ignatius Reilly | Date: | Wed, 03 Sep 2003 15:31:25 +0000 |
| Subject: | Re: Cant get maths functions to work in class file | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-21313@lists.php.net to get a copy of this message | ||
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" <elite_electronics@ntlworld.com>
To: <php-windows@lists.php.net>
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);
>
> ?>
>
>
> mark@harrington.force9.co.uk
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>