Dutch PHP Conference 2027

Yac::__get

(PECL yac >= 1.0.0)

Yac::__getRetrieve a value using property syntax

Beschreibung

public function Yac::__get(string $key): mixed

Retrieves a value from the cache, invoked when reading a property of a Yac instance: $yac->foo is equivalent to $yac->get("foo").

Parameter-Liste

key

The property name, used as the cache key.

Rückgabewerte

The cached value on a hit, null when the key is not present in the cache.

Hinweis:

Unlike Yac::get(), property syntax cannot distinguish a stored null from a missing key, and only supports single keys.

Beispiele

Beispiel #1 Yac::__get() example

<?php
$yac = new Yac();
$yac->set("foo", "bar");

var_dump($yac->foo);       // string(3) "bar"
var_dump($yac->missing);   // NULL
?>

Siehe auch

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top