Я прикрепил файл с кодом - почему (если запустить код на выполение) id второго объекта при копировании отображается правильно, но потом почему-то становится, как у первого: P.S. Не нашел, как тут крепяться файлы, выкладываю так: PHP: <?php define("DEBUG",TRUE); main(); class myVar { private static $_globAmount; private static $_globRealAmount; private $_varVal; private $_varId; public function __construct($value = NULL) { self::$_globAmount++; self::$_globRealAmount++; $this->_varId = self::$_globAmount; $this->_varVal = $value; if (DEBUG) { $report = "An object has been constructed. (Type \"".__CLASS__."\", id \"".$this->_varId."\", value \"".$this->_varVal."\") \n"; echo $report; } return; } public function __destruct() { if (DEBUG) { $report = "An object has been destructed. (Type \"".__CLASS__."\", id \"".$this->_varId."\", value \"".$this->_varVal."\") \n"; echo $report; } self::$_globRealAmount--; $this->_varId = NULL; $this->_varVal = NULL; return; } public function __clone() { self::$_globAmount++; self::$_globRealAmount++; $that->_varId = self::$_globAmount; $that->_varVal = $this->_varVal; if (DEBUG) { $report = "An object has been copied. (Type \"".__CLASS__."\", id \"".$this->_varId."\", value \"".$this->_varVal."\") \n"; echo $report; $report = "An object has been constructed. (Type \"".__CLASS__."\", id \"".$that->_varId."\", value \"".$that->_varVal."\") \n"; echo $report; } return; } protected function __toString() { $varStr = "An object. (Type \"".__CLASS__."\", id \"".$this->_varId."\", value \"".$this->_varVal."\") \n"; return $varStr; } final protected function __set($varName,$varVal) { $errorMsg = "Attribute ".$varName." is private or doesn't exist! So ".gettype($varVal)." value (".$varVal.") will be lost!"; die($errorMsg); return; } final protected function __get($varName) { $errorMsg = "Attribute ".$varName." is private or doesn't exist!"; die($errorMsg); return; } final protected function __call($funcName) { $errorMsg = "Method ".$funcName." is private or doesn't exist!"; die($errorMsg); return; } final public static function getRealAmount() { if (DEBUG) { $report = "Number of existing variables - ".self::$_globRealAmount.". \n"; echo $report; } return self::$_globRealAmount; } final public static function getAmount() { if (DEBUG) { $report = "Number of created variables - ".self::$_globAmount.". \n"; echo $report; } return self::$_globAmount; } public function getId() { if (DEBUG) { $report = "The object id is: ".$this->_varId.". \n"; echo $report; } return $this->_varId; } public function getValue() { if (DEBUG) { $report = "The object value is: ".$this->_varVal.". \n"; echo $report; } return $this->_varVal; } public function setValue($value) { $this->_varVal = $value; if (DEBUG) { $report = "An object has been modified. (Type \"".__CLASS__."\", id \"".$this->_varId."\", value \"".$this->_varVal."\") \n"; echo $report; } return $this->_varVal; } } function main() { $a = new myVar(12); myVar::getRealAmount(); myVar::getAmount(); $b = clone $a; $b->getId(); $b->setValue(123); myVar::getRealAmount(); myVar::getAmount(); echo $a; echo $b; $a = NULL; $b = NULL; myVar::getRealAmount(); myVar::getAmount(); } ?>