PHP 8.6.0 Beta 3 is available for testing

Yaf_Registry::has

(Yaf >=1.0.0)

Yaf_Registry::hasCheck whether an item exists

Descrizione

public static function Yaf_Registry::has(string $name): bool

Checks whether a value exists in the registry.

Elenco dei parametri

name

The name of the registry entry.

Valori restituiti

Returns true if an entry with the given name exists, false otherwise.

Esempi

Example #1 Yaf_Registry::has() example

<?php
class Bootstrap extends Yaf_Bootstrap_Abstract
{
    public function _initRedis(Yaf_Dispatcher $dispatcher)
    {
        /* skip the work if a previous bootstrap pass already did it */
        if (Yaf_Registry::has("redis")) {
            return;
        }

        $config = Yaf_Application::app()->getConfig()->redis;

        $redis = new Redis();
        $redis->connect($config->host, $config->port);

        Yaf_Registry::set("redis", $redis);
    }
}
?>

Vedere anche:

add a note

User Contributed Notes

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