<?php
/**
* -----------------------------------------------
* echo Foo::start(3)->plus(2)->minus(.4);
* -----------------------------------------------
*/
class Foo {
public $init = 0;
public function __construct($num) {
$this->init = $num;
}
public function plus($num) {
$this->init += $num;
return $this;
}
public function minus($num) {
$this->init -= $num;
return $this;
}
public function is() {
return $this->init;
}
public static function start($num) {
return new static($num);
}
public function __toString() {
return $this->is();
}
}
Better than https://codepad.co/snippet/QCYAO5E7
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.