Re: Passing objects into methods or functions

From: Date: Mon, 23 Jun 2003 08:22:27 +0000
Subject: Re: Passing objects into methods or functions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-152478@lists.php.net to get a copy of this message
On Sun, 2003-06-22 at 23:20, Gerard Samuel wrote: > Im trying to pass an object into functions and class methods, and for some > reason, Im unable to access the object's methods. > When I var_dump() the object, its a valid object with the function or > class method. > When I check via get_class_methods, all the methods are there, from > within the function or class method. > I tried passing by reference, and the regular "copied" way. > I end up with the error -> > Fatal error: Call to undefined function: display_thumbnails() in ...... > I can access the object's variables, but not it's methods > > Maybe because Im tired, but if anyone experienced this before, I'd > greatly appreciate any feed back on this. > Thanks Hi there, Besides the fact that my PHP (4.3.2) gives a parse error if I try to name a class 'class' ;), the only thing that is missing here is the '&' where you assign the passed object reference to $this->_tpl. Give that a shot. Hope this helps, Torben > ---------------- > > class class > { > var $_tpl; > var $gal_tpl = array(); > > function gallery_class(&$tpl) > { > if (is_object( $tpl )) > { > $this->_tpl = $tpl; > } > } > } > > ?> -- Torben Wilson <torben@php.net> +1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com -----==== Boycott Starbucks! http://www.haidabuckscafe.com ====-----

« previous php.general (#152478) next »