[ create a new paste ] login | about

Link: http://codepad.org/AEF80xeJ    [ raw code | output | fork ]

PHP, pasted on Nov 30:
<?php

class ClassOne{
    public function methOne($par1,$par2){
        //do something
        echo 'methOne called!';
    }
}

class ClassTwo{
    private $customer;    //initialize $customer in the constructor, to be defined as an instance of ClassOne() class and used as $this->customer

    function __construct() {
        $this->customer = new ClassOne();
    }

    public function methTwo(){
        //some stuff here
        $this->customer->methOne(6,10);    //6,10 - randomly chosen parameters, irrelevant
        //some more stuff here, this doesn't get executed at all
    }
}

$c = new ClassTwo();
$c->methTwo();


Output:
1
methOne called!


Create a new paste based on this one


Comments: