Location: PHPKode > scripts > Destructor > DESTRUCTOR.php
<?php
/**
 * Destructor class for PHP4 implementations.
 * Copyright (C) 2005 - Bryan Smith
 */

$ClassNameObjects = array();

/**
 * Shutdown function which will all all DESTORY_() commands for subsequent classes;
 *
 */
function ClassNameDestructor()
{
	global $ClassNameObjects;

	if (count($ClassNameObjects))
	{
		$ClassnameObject = array_reverse($ClassNameObjects);
		reset($ClassNameObjects);
		
		while(list(, $Obj) = each($ClassNameObjects))
			$Obj->__destructor();

		$ClassNameObjects = null;
	}
}

register_shutdown_function("ClassNameDestructor");

class DESTRUCTOR
{
	/**
	 * References child class into global array.
	 *
	 * @return DESTRUCTOR
	 */
	function DESTRUCTOR()
	{
		global $ClassNameObjects;
		$ClassNameObjects[] = &$this;
	}

	/**
	 * DESTROY_() template.
	 *
	 */
	function __destructor()
	{
		// Default for child destroy
	}
}

?>
Return current item: Destructor