Results 1 to 3 of 3

Thread: Returning value

  1. #1
    Join Date
    Mar 2003
    Location
    SJ, Costa Rica
    Posts
    48

    Red face Unanswered: Returning value

    Hi everybody!,
    We are testing the following class:

    Code:
    a.php:
    
    <?php
    class a
    {
      var $x=1;
      var $y=2;
    
      function getX()
      {
         return $this->x;
      }
    
      function getY()
      {
         return $this->y;
      }
    }
    
    ?>
    We call the class in other php page:

    Code:
    b.php
    
    <?php
       require_once("a.php");
       $nada=new a;
       print "Valor: " . $nada->getY;
    ?>
    but the value of y isn't displayed..
    any hint on what is wrong?
    thanks in advance,
    -eduardo s.m.

  2. #2
    Join Date
    Mar 2003
    Location
    SJ, Costa Rica
    Posts
    48
    I was missing the "()" on getY:

    $nada->getY();

    regards,
    -eduardo s.m.

  3. #3
    Join Date
    Feb 2004
    Posts
    29
    yes of course , to call the function you have to mention its coomplete definition.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •