javascript与php观察者模式

  1. JAVASCRIPT:
    a. 代码:
    var a = function(){
    this.int = 0
    this.add = function(int){
        this.int = int
    }
    this.watch = function(){
        if(this.int==0){
            console.log('0')
        }else{
            console.log('not 0')
        }
    }
    }
    var a = new a()
    a.watch()
    a.add(1)
    a.watch()

    b. 输出:

    成都创新互联公司-专业网站定制、快速模板网站建设、高性价比扎赉诺尔网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式扎赉诺尔网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖扎赉诺尔地区。费用合理售后完善,十余年实体公司更值得信赖。

    0
    not 0
  2. PHP:
    a. 代码:
    int += $int;
    }
    public function watch(){
        if($this->int==0){
            echo "0".PHP_EOL;
        }else{
            echo "not 0".PHP_EOL;
        }
    }
    }
    $a = new a();
    $a->watch();
    $a->add(1);
    $a->watch();

    b. 输出:

    0
    not 0

分享标题:javascript与php观察者模式
当前URL:http://csdahua.cn/article/jppddp.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流