Does php support operator overloading?

后端 未结 2 1193
伪装坚强ぢ
伪装坚强ぢ 2021-01-26 05:55

Does php support operator overloading?

I\'m trying to create a class that takes in a date and I\'d like to compare it with another object without having to use methods o

2条回答
  •  一整个雨季
    2021-01-26 06:46

    PHP doesn't support operator overloading.

    There is an ancient extension which allowed to do this in a manner similar to python. You can find it here.

    That being said, your best bet nowadays is to just use regular methods for comparison.

提交回复
热议问题