[Typo3-dev] Library manager instead of globals

Thorsten Kahler thorsten.kahler at dkd.de
Wed Mar 17 10:35:54 CET 2004


Hi René,

taking a look at the docu at  http://www.php.net/manual/en/ref.funchand.php
I found a function "create_function". This should return a value, which
could be used by "register_shutdown_function":
<cit>
But perhaps the most common use for of lambda-style (anonymous) functions is
to create callback functions, for example when using array_walk() or usort()
</cit>

Perhaps something like this could work:
class xy () {
    function xy() {
        register_shutdown_function(create_function('&$this',
$this->__destruct()));
    }
    function __destruct($c){
        $that = eval($c);
        $that->unregister();
    }
}

Greetings,
Thorsten


> BTW: I have a problem with services related to the fact that php4 have no
real
> destructors.  All my tests with
>
> register_shutdown_function(array(&$this, '__destruct'));
>
> did not work, because the function seems to make a copy of the object and
> don't take the reference. Therefore the data of the object is - while
> destruction - not the same like the 'real' object.
>
> I made many tests and added & to makeInstance() to return a reference but
> nothing works.
>
> Any hints?
>
> greetings
> René

--
COLORCUBE
digital media lab

www.colorcube.de






More information about the TYPO3-dev mailing list