Problem: The PHP manual contains the following content about overloading: & quot; overloading & quot; (overloading) provided by PHP means to dynamically & quot; Create & quot; class attributes and methods. We use magicmethods. For example, _ call ($ funcname, $ arguments) and _ callStatic (... problem:
The reloads in the PHP Manual are as follows: the "overloading" provided by PHP means to dynamically "create" class attributes and methods.
We use magic methods.
For example, _ call ($ funcname, $ arguments) and _ callStatic ($ funcname, $ arguments)
JAVA overload means that multiple methods can be created in the class. they have the same name, but have different parameters and different definitions.
When calling a method, you can determine the method to use by the number and type of different parameters passed to them.
Q: php and java have some differences on the concept of overload, but I don't know what the real difference is?
Reply content:
Problem:
The reloads in the PHP Manual are as follows: the "overloading" provided by PHP means to dynamically "create" class attributes and methods.
We use magic methods.
For example, _ call ($ funcname, $ arguments) and _ callStatic ($ funcname, $ arguments)
JAVA overload means that multiple methods can be created in the class. they have the same name, but have different parameters and different definitions.
When calling a method, you can determine the method to use by the number and type of different parameters passed to them.
Q: php and java have some differences on the concept of overload, but I don't know what the real difference is?
Java is strongly typed
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) { ... }}
The so-called overloading of php is just a rewriting of some magic methods.
There is a good comment in the comment.
This article shocould call this technique "interpreter hooks ".