Page 1 of 1

Calling a Function inside a Function inside a Class

Posted: Thu May 26, 2005 1:19 pm
by bdeonline
I'm trying to call a function inside a function inside a class. I think it can be done I see alot of this in PHPGTK.

Code: Select all

<?php $Move->edit()->images('image'); ?>
Returns: Call to a member function images() on a non-object

Am I doing something wrong or is there something special I have to do to the function first.

Posted: Thu May 26, 2005 2:04 pm
by infolock
post the code please. i have no idea why you are trying to call the function that way as it's not going to work.

the only way i know of how to call a function within a function is to do it within the class itself (or the function).

IE :

Code: Select all

class Foo
{
  function A()
  {
    $this->B();
  }
  function B()
  {
     echo 'heh';
  }
}
So, could you maybe try to explain what you mean a little more clearly? Thanks...


You may just need to look into References

Posted: Thu May 26, 2005 11:00 pm
by harrisonad
Yes it can be done but a little unclean coding style.
Why don't you try it and experiment with it.

Posted: Fri May 27, 2005 8:53 am
by infolock

Code: Select all

<?php

//I guess just try this
$this->Move->edit->images('image');

//or maybe this...notice the reference (&) operator.  Dunno which will work til i see code.
&$this->Move->edit->images('image');
?>