PHP 8.1 – Bessere Performance & neue Funktionen
Inhaltsverzeichnis

<code>class Status
{
const DRAFT = 'draft';
const PUBLISHED = 'published';
const ARCHIVED = 'archived';
}
function acceptStatus(string $status) {...}
</code><code>enum Status
{
case Draft;
case Published;
case Archived;
}
function acceptStatus(Status $status) {...}
</code><code>$fiber = new Fiber(function (): void {
$value = Fiber::suspend('fiber');
echo "Value used to resume fiber: ", $value, PHP_EOL;
});
$value = $fiber->start();
echo "Value from fiber suspending: ", $value, PHP_EOL;
$fiber->resume('test');
</code><code>class Test {
public readonly string $prop;
public function __construct(string $prop) {
// Legal initialization.
$this->prop = $prop;
}
}
$test = new Test("foobar");
// Legal read.
var_dump($test->prop); // string(6) "foobar"
// Illegal reassignment. It does not matter that the assigned value is the same.
$test->prop = "foobar";
// Error: Cannot modify readonly property Test::$prop
</code>Bereit für den Wechsel?
Wechsle jetzt zu cyon für ein souveräneres und nachhaltigeres Internet.
Beteilige dich an der Diskussion
4 Kommentare
Thomas
2. Feb. 2022Philipp Zeder
4. Feb. 2022CYON
Danilo
30. Jan. 2022Philipp Zeder
4. Feb. 2022CYON