Yac::__get

Retrieve a value using property syntax

説明

public mixed Yac::__get(string $key)

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

パラメータ

key
The property name, used as the cache key.

戻り値

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

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

例

例1 Yac::__get example

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

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

参考

  • Yac::get
  • Yac::__set