johnmerlino1 Posted July 30, 2014 Share Posted July 30, 2014 First, I read PHP does not support function overloading. Then later in the book in chapter of OOP, it states: PHP supports function overloading, which means that you can provide more than onefunction with the same name and different numbers or types of parameters. So does it support function overloading or not? And of course my definition of function overloading is what you get in the Java programming language. Quote Link to comment https://forums.phpfreaks.com/topic/290185-php-supports-function-overloading-or-not/ Share on other sites More sharing options...
trq Posted July 30, 2014 Share Posted July 30, 2014 By your definition it does not support function overloading. Quote Link to comment https://forums.phpfreaks.com/topic/290185-php-supports-function-overloading-or-not/#findComment-1486443 Share on other sites More sharing options...
Solution Jacques1 Posted July 30, 2014 Solution Share Posted July 30, 2014 The quote is bollocks, and it worries me that obvious nonsense like this is accepted into a book. Interestingly, chapter 5 says the exact opposite (the truth): You cannot have multiple functions/methods with the same name but different parameters. PHP doesn't even have type declarations of parameters (there's type hinting, but it's limited to classes and arrays). However, the PHP core developers themselves are hopelessly confused about the term “overloading”: On the one hand, they've redefined it to describe magical methods like __set() and __get(). Then it's used with yet another definition in the mbstring extension where it simply means that the default string functions are replaced with mbstring functions. So now we have three different definitions: The “official” one as used everywhere outside of PHP, and two different definitions used in the PHP world. How helpful. Quote Link to comment https://forums.phpfreaks.com/topic/290185-php-supports-function-overloading-or-not/#findComment-1486448 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.