Does php support operator overloading?

后端 未结 2 1181
伪装坚强ぢ
伪装坚强ぢ 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:42

    PHP's interpretation of "overloading" is different than most object oriented languages. Overloading traditionally provides the ability to have multiple methods with the same name but different quantities and types of arguments.

    I hope this link will help you to understand concept,

    http://php.net/manual/en/language.oop5.overloading.php

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题