Problem:
The contents of the PHP manual for overloading are as follows: PHP provides a "reload" (overloading) that refers to dynamically "create" class properties and methods.
We do this by means of magic methods.
such as __call ($funcname, $arguments), __callstatic ($funcname, $arguments)
Overloading in the Java language refers to the ability to create multiple methods in a class that have the same name but have different parameters and different definitions.
Methods are invoked by the number of different arguments and parameter types passed to them to determine which method to use.
Question: PHP and Java on the concept of overloading is certainly a difference, but do not know what the real difference is?
Reply content:
Problem:
The contents of the PHP manual for overloading are as follows: PHP provides a "reload" (overloading) that refers to dynamically "create" class properties and methods.
We do this by means of magic methods.
such as __call ($funcname, $arguments), __callstatic ($funcname, $arguments)
Overloading in the Java language refers to the ability to create multiple methods in a class that have the same name but have different parameters and different definitions.
Methods are invoked by the number of different arguments and parameter types passed to them to determine which method to use.
Question: PHP and Java on the concept of overloading is certainly a difference, but do not know what the real difference is?
Java is a 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) { ... }}
PHP's so-called overloading, just a similar rewrite of some magical methods
There's a good word in the comments.
This article should call this technique "interpreter hooks".