Duplicated methods |
[eluser]Lark[/eluser]
Code: class Test extends Controller If i request: /test/mymethod/ "My method with no parameters" will be returned. And if i try: /test/mymethod/45 "My method with one parameter: 45" will be returned. I have tried but with no success. If it's not possible, maybe this would be a good future implementation?
[eluser]Rick Jolly[/eluser]
What you are describing is method overloading as it applies to most OOP programming languages. PHP's definition of method overloading is totally different. You can use default parameters instead: Code: function mymethod($id = null)
[eluser]marcoss[/eluser]
[quote author="Rick Jolly" date="1184111418"]What you are describing is method overloading as it applies to most OOP programming languages. PHP's definition of method overloading is totally different. You can use default parameters instead: Code: function mymethod($id = null) That works as he pretends, but it is definitely not method overloading. You should check this out if you want to know the PHP way of doing it http://www.php.net/manual/en/language.oo...oading.php
[eluser]Rick Jolly[/eluser]
[quote author="marcoss" date="1184777530"] You should check this out if you want to know the PHP way of doing it http://www.php.net/manual/en/language.oo...oading.php[/quote] Since PHP's version of "method overloading" (really unfortunate name) had nothing to do with Lark's question, discussing it wouldn't have been helpful. |
Welcome Guest, Not a member yet? Register Sign In |