still not working: why?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vinnie

    still not working: why?

    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_somm a();
    $sum=$somma->(34,40);
    print("$sum");
    }

  • Jerry Stuckle

    #2
    Re: still not working: why?

    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_somm a();
    $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.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • enzo.now@gmail.com

      #3
      Re: still not working: why?

      On May 28, 10:05 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
      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_somm a();
      $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...@attgl obal.net
      =============== ===
      so, writing back the whole algorithm, how should it be?
      thanks

      Comment

      • Schraalhans Keukenmeester

        #4
        Re: still not working: why?

        At Mon, 28 May 2007 16:56:34 -0700, vinnie let h(is|er) monkeys type:
        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_somm a();
        $sum=$somma->(34,40);
        print("$sum");
        }
        Vinnie, are you sure this isn't homework (again!) ? Your first msg clearly
        stated:
        please help me, i have a test!
        I cannot help but think you hardly have a clue about PHP's syntax and
        semantics. If you read the replies carefully the answer is already there,
        but it seems you just want us to deliver the working code for you.

        Sorry, no can do.


        --
        Schraalhans Keukenmeester - schraalhans@the .spamtrapexampl e.nl
        [Remove the lowercase part of Spamtrap to send me a message]

        "strcmp('apples ','oranges') is -1"

        Comment

        • Erwin Moller

          #5
          Re: still not working: why?

          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" );
          Hi Vinnie,

          Why do you first return something, and then print something on the next
          line?
          What do you think will happen?
          Will the print-statement ever be reached?

          Regards,
          Erwin Moller
          }
          $somma=new_somm a();
          $sum=$somma->(34,40);
          print("$sum");
          }

          Comment

          • vinnie

            #6
            Re: still not working: why?

            On May 29, 3:54 am, Erwin Moller
            <since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
            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" );
            >
            Hi Vinnie,
            >
            Why do you first return something, and then print something on the next
            line?
            What do you think will happen?
            Will the print-statement ever be reached?
            >
            Regards,
            Erwin Moller
            >
            }
            $somma=new_somm a();
            $sum=$somma->(34,40);
            print("$sum");
            }
            but also if i try to echo $sum, i get nothing, so there must be a
            mistake somewhere, and using the 2 books i have it's hard to find
            (PHP5 for dummies, and core PHP programming).

            Comment

            • Jerry Stuckle

              #7
              Re: still not working: why?

              vinnie wrote:
              On May 29, 3:54 am, Erwin Moller
              <since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
              >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_FUNCTIO N 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($total e);
              >> }
              >> function sum_2()
              >> {
              >> $totale = $this->sum($this->uno, $this-
              >>>due, $this->tre);
              >> return $totale;
              >> print("$totale" );
              >Hi Vinnie,
              >>
              >Why do you first return something, and then print something on the next
              >line?
              >What do you think will happen?
              >Will the print-statement ever be reached?
              >>
              >Regards,
              >Erwin Moller
              >>
              >> }
              >>$somma=new_so mma();
              >>$sum=$somma->(34,40);
              >>print("$sum") ;
              >> }
              >
              but also if i try to echo $sum, i get nothing, so there must be a
              mistake somewhere, and using the 2 books i have it's hard to find
              (PHP5 for dummies, and core PHP programming).
              >
              First of all, turn on all errors in your php.ini file and display them:

              error_reporting = E_ALL
              display_errors = On

              So you can see your errors. That should help you a little bit.

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              Working...