Hello people,
can anyone help me and add a class into my code and put all the functions into that class i am stuck on this step all works but I don’t know how to put my functions into a class…
here is my code:
[php]
Calc <?php $x=4.5; $y=5.5; $a=20; $b=10;function hello() {
print “
HELLO!
”;print “
Welcome to my web site
”;}
function printBreak($text) {
print “$text
”;
}
function addNumbers() {
global $x,$y;
$y=$x+$y;
}
function addNumbers1() {
global $a,$b;
$a=$b-$a;
}
hello();
printBreak(“This is a line”);
addNumbers();
echo $y. " - SUM
";
addNumbers1();
echo $a. " - SUB
";
// for loop
$total = 0;
for ($y ; $y<=100; $y++) {
$total = $total + $y;
}
echo $total . " - For Loop
";
$a;
$sum = 0;
while($a<=100)
{
$sum += $a;
$a++;
}
echo $sum . " - While Loop
";
if ($total > $sum) {
echo “for loop is bigger than while loop”;
} elseif ($total == $sum) {
echo “for loop is equal to while loop”;
} else {
echo “for loop is smaller than while loop”;
}
?>
[/php]