Home >Backend Development >PHP Tutorial >PHP和JAVA中的重载(overload)和覆盖(override) 介绍_PHP

PHP和JAVA中的重载(overload)和覆盖(override) 介绍_PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 12:13:301514browse

重载:同一个类中,函数名一样,返回值或者参数类型,个数不一样的叫做重载。
覆盖:同名函数,同返回值类型,同参数的叫做覆盖。指的是子类对父类中方法的覆盖。
PHP不支持方法和操作符重载。JAVA不支持操作符的重载(但是“+”实际上是一种操作符重载)。
复制代码 代码如下:
Class Father {
public function fmeth1() {
echo "fmeth1()...
";
}
//public function fmeth1($str1) {
// echo "fmeth1() with $str1...
";
/

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn