PHP 8.4.26 Released!

Yaf_Registry::__construct

(Yaf >=1.0.0)

Yaf_Registry::__construct — Constructor of Yaf_Registry

Опис

privatefunction Yaf_Registry::__construct()

The constructor is private: Yaf_Registry implements the singleton pattern and cannot be instantiated directly. Use the static methods to read and write registry entries.

Параметри

У цієї функції немає параметрів.

Значення, що повертаються

No value is returned.

Приклади

Приклад #1 Yaf_Registry::__construct() example

The constructor is private, so direct instantiation is rejected:

<?php
$registry = new Yaf_Registry();
?>

Поданий вище приклад виведе щось схоже на:

PHP Fatal error:  Uncaught Error: Call to private Yaf_Registry::__construct() from invalid context

Приклад #2 Using Yaf_Registry through its static methods

<?php
Yaf_Registry::set("version", Yaf_Application::app()->getConfig()->application->version);
var_dump(Yaf_Registry::get("version"));
?>

Поданий вище приклад виведе щось схоже на:

string(7) "1.0.0.1"

Прогляньте також

+add a note

User Contributed Notes

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