gc_enabled
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
gc_enabled — 返回循环引用计数器的状态
说明
gc_enabled(): bool
返回循环引用计数器的状态。
参数
此函数没有参数。
返回值
如果垃圾收集器已启用则返回 true
,否则返回 false
。
范例
示例 #1 一个 gc_enabled() 例子
<?php
if(gc_enabled()) gc_collect_cycles();
?>

User Contributed Notes 1 note
Anonymous ¶
12 years ago
If I understand correctly, the php.ini parameter zend.enable_gc (see http://www.php.net/manual/en/info.configuration.php) determines whether garbage collection is enabled:
<?php
var_dump(gc_enabled());
ini_set('zend.enable_gc', 0);
var_dump(gc_enabled());
?>
In PHP 5.3.0 this prints:
bool(true)
bool(false)
Oh, and of course gc_enable() and gc_disable() turn on or off the collection of garbage.