|
Posted by enzo.now on 05/29/07 03:16
On May 28, 10:05 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> vinnie wrote:
> > hi guys, i'm just at the beginning. I apologize. the file still gives
> > me back an error:
>
> > <<Parse error: syntax error, unexpected T_VARIABLE, expecting
> > T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in d:\tryphp.php on line
> > 19>>
>
> > why? Can someone fix it so i can "study" the working one?
>
> > class somma
> > {
> > var $uno=10;
> > var $due=15;
> > var $tre=15;
> > function sum($uno,
> > $due, $tre)
> > {
>
> > $totale = $uno + $due + $tre;
>
> > return($totale);
> > }
> > function sum_2()
> > {
> > $totale = $this->sum($this->uno, $this-
> >> due, $this->tre);
> > return $totale;
> > print("$totale");
> > }
> > $somma=new_somma();
> > $sum=$somma->(34,40);
> > print("$sum");
> > }
>
> You didn't tell what function to call.
>
> When you create an object, you create something with both properties and
> methods. You interact with the properties through the methods.
>
> In this case you're not really using any of the properties of the class
> ($uno, $due, $tre). Rather, you're just trying to call a function with
> some parameters.
>
> OOP is a very different way of thinking, but (IMHO) a much superior way
> of programming.
>
> For instance, in your class, you might want functions to set
> $somma->uno, $somma->dup and $somma->tre, then have a function which
> would add the three. While not particularly useful in this instance, it
> would be a more accurate example of OOP.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================
so, writing back the whole algorithm, how should it be?
thanks
Navigation:
[Reply to this message]
|