In the 5 minutes i took to test it out, it seems that register_shutdown doesn't seem to like object methods (?) I did come up with a solution, but it't not really the best way to do things.... put cRoute_Destructor() into the same file as the class declarations, so that when you include() the class, you'll get access to cRoute_Destructor, and to the user, it will appear to all run smoothly.
// start of cRoute.inc class cRoute{ function cRoute(){ register_shutdown_function('cRoute_Destructor',$this); } function cleanup(){ print "Please call close()"; $this->close(); } function close(){ //close open sockets, etc. } } // End of class function cRoute_Destructor($x) { $x->cleanup(); } // end of cRoute.inc $test = new cRoute(); exit; -- Scott Hurring Systems Programmer EAC Corporation scott (*) eac.com -- "Sqlcoders.Com Programming Dept" <[EMAIL PROTECTED]> wrote in message 00ce01c211dd$32079ec0$6520fea9@dw">news:00ce01c211dd$32079ec0$6520fea9@dw... > > This is completely off the top of my head (i've never done this > > before) -- but try single-quoting it to prevent interpolation > > > > register_shutdown_function('$this->cleanup()'); > > > > Hiya, > thanks for the suggestion, but i get the same 'Unable to call ...' message. > Any other ways you can think of? > I tried the following: > '$this->cleanup()' > '$this->cleanup' > > I also tried the :: syntax but it woudlnt work, plus the actions to be > performed rely on data contained within the instance. > > TIA, > Dw. > > > > -- > > Scott Hurring > > Systems Programmer > > EAC Corporation > > scott (*) eac.com > > -- > > "William_dw -- Sqlcoders" <[EMAIL PROTECTED]> wrote in message > > 009401c211d9$a1863da0$6520fea9@dw">news:009401c211d9$a1863da0$6520fea9@dw... > > > Hi there!, > > > I'm trying to emulate a class destructor, according to the PHP > documentation > > > I can emulate this by using a call to register_shutdown_function(), > > > containing the function to be called upon shutdown. > > > > > > While this apparently works outside a class, I want to use it inside a > > > class, in other words I want to have something like this: > > > > > > class cRoute{ > > > function cRoute(){ > > > //register the shutdown function in case people who use this > class > > > dont call the appropiate close methods. > > > register_shutdown_function("cleanup()"); > > > } > > > > > > function cleanup(){ > > > //cleanup. > > > trigger_error("Please call close() before the page ends, to > prevent > > > problems close() has been called automatically for you."); > > > $this->close(); > > > } > > > > > > function close(){ > > > //close open sockets, etc. > > > } > > > } > > > > > > I have tried: > > > register_shutdown_function("cleanup()"); > > > register_shutdown_function("$this->cleanup()"); > > > register_shutdown_function($this->cleanup()); > > > register_shutdown_function("cDB::cleanup()"); > > > > > > They all return something like: Warning: Unable to call ()() - function > does > > > not exist in Unknown on line 0 > > > > > > If anyone has any ideas I'd appreciate the help. > > > Thanks in advance!, > > > Dw. > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php