Re: Re: Re: PHP5 object construct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ok, so if we were talking Java, perhaps you are looking for
information that allows you to build 'accessor' and 'mutator' methods?
If so, then your example should work (syntax aside). Here's another
'test' example that I just whipped up and tested that shows you can
use any method name you wish.

<?php
class test {

 private $thing;

 function setThing($val) {
   $this->thing = $val;
 }


 function getThing() {
   return $this->thing;
 }

}

$t = new test;

// Show that thing is empty
print $t->getThing() . "\n";

// Set thing to 'Thing'
$t->setThing('Thing');

// show that thing contains 'Thing'
print $t->getThing() . "\n";
?>


If I'm still on the wrong path I apologize. I probably shouldn't be
trying to provide advice on cold medicine ;-)



On 9/22/06, Chris Boget <chris.boget@xxxxxxxx> wrote:
> well, perhaps I'm not seeing what it is that you're looking for.

No, I'm not sure you are.  Take a look at my sample code again.  Pay
particular attention to how both $bob and $Bob are defined.

class MyClass {

  private $bob;

  public $Bob {
    set( $var ) {
      $this->bob = $var;

    }
    get() {
      return $this->bob;

    }
  }
}

thnx,
Chris




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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux