Регистрация Войти
Войти через VK Войти через FB Войти через Google Войти через Яндекс
Войти через VK Войти через FB Войти через Google Войти через Яндекс
Поиск по сайту
Наш чат в Telegram для обмена идеями, проектами, мыслями, людьми в сфере ИТ г.Ростова-на-Дону: @it_rostov
The Weakref class
(Информация о версии неизвестна, возможно, только в SVN)
Введение
The Weakref class provides a gateway to objects without preventing the garbage collector from freeing those objects. It also provides a way to turn a weak reference into a strong one.
Обзор классов
Weakref {
/* Методы */
public __construct ([ object $object ] )
public bool acquire ( void )
public object get ( void )
public bool release ( void )
public bool valid ( void )
}
Примеры
Пример #1 Weakref usage example
class MyClass {
public function __destruct() {
echo "Destroying object!\n";
}
}
$o1 = new MyClass;
$r1 = new Weakref($o1);
if ($r1->valid()) {
echo "Object still exists!\n";
var_dump($r1->get());
} else {
echo "Object is dead!\n";
}
unset($o1);
if ($r1->valid()) {
echo "Object still exists!\n";
var_dump($r1->get());
} else {
echo "Object is dead!\n";
}
Результат выполнения данного примера:
Object still exists! object(MyClass)#1 (0) { } Destroying object! Object is dead!
Содержание
- Weakref::acquire — Acquires a strong reference on that object
- Weakref::__construct — Constructs a new weak reference
- Weakref::get — Returns the object pointed to by the weak reference
- Weakref::release — Releases a previously acquired reference
- Weakref::valid — Checks whether the object referenced still exists
Описание класса weakref, примеры использования класса weakref.
Смотрите также:
Описание на ru2.php.net
Описание на php.ru