Classes / Methods

<?php

namespace ClassMethods;

class Counter {
    public $count = 0;

    function incBy($value) {
        $this->count += $value;
    }

    function incByAmount($value, $amount) {
        $this->count += $value * $amount;
    }
}

$counter = new Counter();
$counter->incBy(1);
//counter.count is 1
echo $counter->count"\n";

$counter->incByAmount(25);
//counter.count is 11
echo $counter->count"\n";