Question:
The content about overloading in the PHP manual is as follows: The "overloading" provided by PHP refers to dynamically "creating" class attributes and methods.
We do it through magic methods.
Such as __call($funcname, $arguments), __callStatic($funcname, $arguments)
Overloading in the JAVA language means that multiple methods can be created in a class. They have the same name but different parameters and different definitions.
When calling methods, determine which method to use based on the number and type of parameters passed to them.
Question: There is definitely a difference in the concepts of overloading between PHP and Java, but I don’t know what the real difference is?
Question:
The content about overloading in the PHP manual is as follows: The "overloading" provided by PHP refers to dynamically "creating" class attributes and methods.
We do it through magic methods.
Such as __call($funcname, $arguments), __callStatic($funcname, $arguments)
Overloading in the JAVA language means that multiple methods can be created in a class. They have the same name but different parameters and different definitions.
When calling methods, determine which method to use based on the number and type of parameters passed to them.
Question: There is definitely a difference in the concepts of overloading between PHP and Java, but I don’t know what the real difference is?
Java is strongly typed
<code>public class DataArtist { ... public void draw(String s) { ... } public void draw(int i) { ... } public void draw(double f) { ... } public void draw(int i, double f) { ... } }</code>
The so-called overloading of PHP is just a similar rewriting of some magic methods
There is a good saying in the comments
This article should call this technique "interpreter hooks".