Calling a Function inside a Function inside a Class

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bdeonline
Forum Commoner
Posts: 42
Joined: Sun Jul 18, 2004 10:45 am

Calling a Function inside a Function inside a Class

Post 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.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

Post by harrisonad »

Yes it can be done but a little unclean coding style.
Why don't you try it and experiment with it.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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');
?>
Post Reply