Operator Overloading¶
PHP has no operator overloading in the userland, but it may be achieved by using an extension.
Bcmath has taken advantage of it since PHP 8.3, where it introduced the Number class.
With feature, it is possible to go beyond the 14 decimal digits of standard PHP configuration.
On the other hand, the underlying library’s limitation are also applied, so using the ** operator on decimal Number yield a exponent cannot have a fractional part, which does not appear in the standard PHP operation.
See Also¶
Overloading Multiplication [Try me]
Overloading Exponent [Try me]