calling a method from within a class??

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

    calling a method from within a class??

    hi all,

    just wondering what the syntax is for calling a method of a class from
    another method of that same class?

    for example...

    class Test {
    var $test="foo";
    function printTest() {
    print $this->test;
    }
    function callMethod() {
    // call the printTest() function
    }
    }

    what is the code i need to put in the callMethod() method to call the
    printTest() method???

    thanks in advance

    JP


  • Chris Hope

    #2
    Re: calling a method from within a class??

    kingofkolt wrote:
    [color=blue]
    > just wondering what the syntax is for calling a method of a class from
    > another method of that same class?
    >
    > for example...
    >
    > class Test {
    > var $test="foo";
    > function printTest() {
    > print $this->test;
    > }
    > function callMethod() {
    > // call the printTest() function
    > }
    > }
    >
    > what is the code i need to put in the callMethod() method to call the
    > printTest() method???[/color]

    $this->printTest();

    Chris

    --
    Chris Hope
    The Electric Toolbox Ltd

    Comment

    • kingofkolt

      #3
      Re: calling a method from within a class??

      "Chris Hope" <blackhole@elec trictoolbox.com > wrote in message
      news:40848742_5 @news.athenanew s.com...[color=blue]
      > kingofkolt wrote:
      >[color=green]
      > > just wondering what the syntax is for calling a method of a class from
      > > another method of that same class?
      > >
      > > for example...
      > >
      > > class Test {
      > > var $test="foo";
      > > function printTest() {
      > > print $this->test;
      > > }
      > > function callMethod() {
      > > // call the printTest() function
      > > }
      > > }
      > >
      > > what is the code i need to put in the callMethod() method to call the
      > > printTest() method???[/color]
      >
      > $this->printTest();
      >
      > Chris
      >
      > --
      > Chris Hope
      > The Electric Toolbox Ltd
      > http://www.electrictoolbox.com/[/color]

      well that was simple enough... thx!!

      JP


      Comment

      Working...