RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
javascript与php单例模式

一、JAVASCRIPT:

  1. 代码:
    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()
  2. 输出:
    ab

    二、PHP:

  3. 代码:
    out .= $a;
        return $this;
    }
    public function b($b){
        $this->out .= $b;
        return $this;
    }
    public function say(){
        echo $this->out.PHP_EOL;
    }
    public function get(){
        return $this->out;
    }
    }
    $single = new single();
    $out = $single->a('a')->b('b')->say();
    $get = $single->a('a')->b('b')->get();
    echo $get;
  4. 输出:
    ab
    abab

文章题目:javascript与php单例模式
文章起源:http://scyingshan.cn/article/jheigh.html