Monday, March 24, 2014

OOPs in PHP :- Simple example of class

<?php
class bank
{
var $amt=1000;

function deposite($dep)
{
echo "Balance in the account ".$this->amt."<br/>";
$this->amt=$this->amt+$dep;
echo "Balance after deposite money ".$this->amt;
echo "<br/>";
}
function withdraw($wd)
{
$this->amt=$this->amt-$wd;
echo "Balance after withdraw money ".$this->amt;
}
}
$b=new bank();
$b->deposite(500);
$b->withdraw(200);
?>

Output:-



No comments:

Post a Comment