29 December, 2010

PHP Multiply Variables Example Class

<?php
class multiply{
    private $x;
    private $y;

    public function set_x($input_x){
        $this->x = $input_x;
    }

    public function set_y($input_y){
        $this->y = $input_y;
    }

    public function get_result(){
        return $this->x * $this->y;
    }

}

#create an instance of a class
$multy = new multiply();
#set variable x
$multy->set_x(10);
#set variable y
$multy->set_y(10);
#echo the result
echo $multy->get_result();
?>

No comments:

Post a Comment