Beispiel #1
0
    }
    public function hello()
    {
        return "Hello world";
    }
    public function creating($model)
    {
        Mail::send(array("body" => Module::template('signup-confirmation')->compile(array("base_url" => AppConfig::get("retrieve.email.url"))), "subject" => "Sign-up confirmation", "to" => $model->email, "from" => "*****@*****.**"));
    }
    public function updating($model)
    {
        if ($model->isDirty('status') && $model->status == 1) {
            Mail::send(array("body" => Module::template('signup-approved')->compile(array("BASE_URL" => AppConfig::get("retrieve.email.url"))), "subject" => "Approved!", "to" => $model->email, "from" => "*****@*****.**"));
        }
    }
    function __get($_property)
    {
        if ($_property === 'something') {
            return "Something: " + $this->_something;
        }
    }
    function __set($_property, $value)
    {
        if ($_property === 'something') {
            $this->_something = $value + 10;
        }
    }
}
$example = new ClassExample("awesome");
var_dump(call_user_func_array(array($example, 'hello'), array()));
var_dump($example->hello());
    private function privateFunction()
    {
        return 5;
    }
    public function publicAccess()
    {
        return $this->privateFunction();
    }
    public function testFunctionStatic()
    {
        static $countUnique = 0;
        $countUnique++;
        return $countUnique;
    }
}
$classExample = new ClassExample(5);
$classExample->addValue(5);
assert($classExample->value, 10);
assert($classExample->getArrayValue(), 6);
assert($classExample->getArrayValueWithIndex(), 6);
$classExample->testStatic();
$classExample->testStatic();
$result = $classExample->testStatic();
//Called two times, but value is only incremented twice
assert($result, 2);
$privateAccessed = false;
$exceptionCaught = false;
try {
    //Yes IDE - I know this isn't allowed.
    ///** @noinspection PhpIllegalArrayKeyTypeInspection */
    // @SuppressWarnings