Skip to content

Instantly share code, notes, and snippets.

@imjacobclark
Created June 6, 2012 21:09
Show Gist options
  • Save imjacobclark/2884780 to your computer and use it in GitHub Desktop.
Save imjacobclark/2884780 to your computer and use it in GitHub Desktop.
OOP Calculator
<?php
class Calc{
public $input;
public $input2;
public $output;
function setInput($int){
$this->input = (int) $int;
}
function setInput2($int){
$this->input2 = (int) $int;
}
function Calculate(){
$this->output = $this->input + $this->input2;
}
function getResult(){
return $this->output;
}
}
$calc = new Calc();
$calc->setInput(5);
$calc->setInput2(22);
$calc->Calculate();
echo $calc->getResult();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment