sdchy 发表于 2018-12-12 10:28:33

javascript与php单例模式

一、JAVASCRIPT:


[*]代码:
var test = function (){
this.str = '',
this.a = function (){
this.str += "a"
return this
},
this.b = function(){
this.str += "b"
return this
}
this.out = function(){
console.log(this.str)
}
}
var entity = new test()
entity.a().b().out()
[*]输出:
ab
二、PHP:
[*]代码:
页: [1]
查看完整版本: javascript与php单例模式