php8.5
Home/ Manual/ yac / yac/ Yac::__get

Yac::__get

PHP function Edit on GitHub ✎

(PECL yac >= 1.0.0)

Retrieve a value using property syntax

Description

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").

Parameters

key

The property name, used as the cache key.

Return Values

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

Note

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

Examples

Yac::__get example

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

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

See Also

  • Yac::get
  • Yac::__set

Source: reference/yac/yac/getter.xml · from the official PHP manual (php/doc-en)