Home > php教程 > php手册 > php函数重载的替代方法--伪重载详解

php函数重载的替代方法--伪重载详解

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:04:13
Original
1568 people have browsed it

对于弱类型语言来说,PHP函数重载,并不像一般的OOP那样。而弱类型本来就不区分,所以无法通过这些来实现。但是,可以通过下面的方法来实现简单的伪重载吧。

函数重载的替代方法-伪重载,下面看一个具体的实例代码。

test1( $_arg [ 0 ] ); break ; case 2 : $this -> test2( $_arg [ 0 ] , $_arg [ 1 ]); break ; default : $this -> a = 0 ; $this -> b = 1 ; break ; } } function test1 ($a) { $this -> a = $a ; } function test2 ($a, $b) { $this -> a = $a ; $this -> b = $b ; } } ?>

以上所述就是本文的全部内容了,希望大家能够喜欢。

Related labels:
php
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template