On 12/03/2014 01:40 PM, Robert Stoll wrote:
> Heya, 
> 
>  
> 
> I would like to know If it is somehow possible to overload existing functions 
> by extensions. And if it is possible, are
> there already some extension doing it?
> 
> I am not talking about the magic __call function. I am talking about 
> something like: let's assume GMP has overloaded the
> function "abs" and therefore one can write:
> $n = gmp_init(-12345678901234567890);
> abs($n+ 2);  // instead of using gmp_abs
> 
>  
> 
> I know that GMP has overloaded operators so it doesn't seem so far that 
> overloading functions is possible as well.

Yes, it is possible and you can see an example in /ext/mbstring's RINIT
function. It just loops through and replaces the entries in the function
table. No real magic there.

Note though that this is pretty ugly and since it is in the RINIT it
means it will happen on every single request regardless of whether any
of these functions are called during the request. As a quick local hack
you can do it though.

-Rasmus


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to