¡¡¡¡Ëae×ÅÃaeÏo¶ÔÏo±a³ÌµÄÆÕ±eÕ¹¿ª£¬ÃaeÏo¶ÔÏoÕ¹ÏÖÁËÆaÖкܶaÓÐȤµÄÎÊÌa¡£ÏaÐźܶa³oѧÕßѧϰphpÃaeÏo¶ÔÏoʱ»a½Ó´¥Á½¸oº¯Êý£¬¹¹Ôiº¯ÊýÓeÎo¹¹º¯Êý¡£¹¹Ôiº¯ÊýËƺoÓõĸu¶a£¬Îo¹¹º¯ÊýÓõĽÏÉÙ£¨Ïa¶Ô³oѧÕßÓÐÏÞ±a³Ì¾Ñe¶øÑÔ£¬±ÊÕßÒ²ÊÇÈç´Ë¡££(C)ÔÚ¹¦ÄÜÉÏ£¬¹¹Ôiº¯ÊýÔÚ´´½¨¶ÔÏoʱµ÷Óã¬Îo¹¹º¯ÊýÔÚ¶ÔÏoÏu»Ùʱµ÷Ó㬶¼ÎÞÐeÌØÒaÈ¥µ÷Óã¬Ò»Í*һ⣬µ¹Ò²ÊÇÇ°ºoÕÕÓ¦¡£
¡¡¡¡Îo¹¹º¯Êý³£³£´¦ÀiµÄÊÂÎñÊÇÒ»Ð(C)×ÊÔ´ÊÍ*ŵŤ×÷£¬±ÈÈçÇ°ÃaeÓÐfopen(),ÕaÀiµ÷ÓÃfclose(),Ç°ÃaeÓÐimagecreatefromjepg(),ÕaÀiµ÷ÓÃimagedestory()£¬ÕaÐ(C)¶¼ÊÇÐ(C)³£¼uµÄÀý×Ó£¬µ±È»²»¾ÖÏÞÓÚ´Ë¡£ÎÒÃÇ´o¿É½«Æaµ±×oÒ»¸oÆÕͨµÄ»aÔÚ¶ÔÏoÏu»Ù»oÕ߽ű¾Ö´ÐÐÍe±ÏµÄʱºoÖ´Ðеĺ¯Êý¡£
¡¡¡¡†ªaÂÄÇô¶a£¬»¹ÊǾ¡ÔçÌa³o½ñÌiµÄÖ÷ÒªµÄÎÊÌa£º
<?php
class Test{
public function __destruct(){
echo "Ö´ÐÐÎo¹¹º¯Êý";
}
}
$test1=new Test;
$test2=$test3=$test1;
unset($test1);
echo "<hr/>";
¡¡¡¡Õa¶Î½Å±¾Ö´Ðнa¹uÊÇʲô£¿
¡¡¡¡ÔڻشðÕa¸oÎÊÌa֮ǰ£¬»Ø¿´ÎÒÉÏÃae±eʾµÄ¼¸¸o×Ö¡£ÎÒÃÇ¿ÉÒÔÀiËuÓ¦µ±µÄÈÏΪÔÚÊa³oÖ¸oÏßÇ° unset($test1) ,ÕaÑu»aµ÷ÓÃÎo¹¹º¯Êý£¬Êa³oÎÄ×Ö£¬ÖÁÓÚ $test2,$test3 Ó¦¸Ã»aÔڽű¾Ö´ÐÐÍe±Ïµ÷ÓÃÎo¹¹º¯Êý¡£Ò²¾ÍÊÇ˵£¬ÔÚÖ¸iÏßÉÏÃae£¬»aÊa³oÒ»¶ÎÎÄ×Ö£¬*Ö¸oÏßÏÂÃae»aÊa³oÁ½¶ÎÎÄ×Ö¡£ ÔÚÕa¸oʱºo£¬´o¿ÉÒÔС½¾°Áһϣ¬±Ï¾¹×Ô¼º¶®µÃʲôʱºoµ÷ÓÃÎo¹¹º¯Êý¡£µ«ÏÖʵÕaeÊÇÈç´Ëô£¿ÎÒÃÇ¿ÉÒÔ¿´Ò»ÏÂÖ´Ðнa¹u¡£
¡¡¡¡ºÙ£¬Ëuß÷µÄ£¬Ôoô¾ÍÊa³oÁËÒ»¾a°¡£¿£¿£¿
¡¡¡¡ÆaʵÎÒÃǺoÂÔÁËÒ»¸oÖØÒªµÄÇ°ÌaÌo¼þ£¬¾ÍÊǶÔÏoµÄ¸³ÖµÄ¬ÈϵÄÊÇÒýÓø³Öµ¡£ÕaÒ»µaºÜ¶aÈËûÓÐ×¢Òaµ½£¬Ï£Íu³oѧÕßÄܶa¶a×¢Òaһϡ£
¡¡¡¡ÄÇô¼ÈÈ»ÊÇÒýÓø³Öµ£¬½aºÏÎÒÃǶÔÆÕͨ±aÁ¿µÄÀi½a£¬ÎÒÃǺܿiÏeµ½£¬Èý¸o±aÁ¿ÃuÖ¸Ïoͬһ¿e´ae´¢µØÖ¡£ÄÇô¼ÈÈ»Èç´ËµÄ»°£¬ unset($test1) Æðµ½µÄÊÇʲô×÷Óã¿£¿£¿ÆÆ»µ±aÁ¿Ö¸Ïo´ae´¢µØÖ»¹ÊÇÆÆ»µ´ae´¢µØÖ*´ae´¢µÄÄÚÈÝ£¿
¡¡¡¡Á˽aunset()º¯ÊýÓÃ*¨µÄÇeÖ±¾oÌø¹ý±¾¶Î¡£
¡¡¡¡Ïe×ÅÕaµ°ÌÛµÄÎÊÌa£¬Äª²»ÈçÈ¥²e¿´ÊÖ²a¡£
¡¡¡¡Í¬ÑuÊÇ´«µÝÒýÓ㬻ٵoµÄ½o½oÊDZaÁ¿ÃuÖ¸Ïo´ae´¢µØÖ¡£½aºÏƽ³£unset()µÄ×÷Óã¬ÎÒÃÇ¿ÉÒÔÕaôÃeÊo£¬µ±¶a¸o±aÁ¿Ãu»oÕ߶ÔÏoÃuÖ¸ÏoÒ»¿e´ae´¢µØÖʱ£¬unset()º¯ÊýµÄ×÷Óýo½oÊÇÏu»Ù±aÁ¿ÃuºÍ´ae´¢µØÖµÄÖ¸Ïo¶øÒÑ£¬µ±½oÓÐÒ»¸o±aÁ¿Ãu»oÕ߶ÔÏoÃu£¬unsetÏu»ÙµÄÊÇÖ¸¶¨µÄ´ae´¢µØÖÉϵÄÄÚÈÝ¡£
¡¡¡¡ÎÒÃÇ¿ÉÒÔÏeÏoÕaeʵµÄ´ae´¢ÄÚÈÝÊÇһ̨µçÊÓ¡£¶a¸oÈË£¨¶a¸o±aÁ¿Ãu»o¶ÔÏoÃu£(C)ÔÚ¿´Ò»Ì¨µçÊÓ¡£unset()ºo£¬Ò»¸oÈ˲»¿´ÁË£¬Àe¿ªÁË£¬µçÊÓ»¹¿ª×Å¡£µ±Ö»ÓÐÒ»¸oÈË¿´µçÊÓµÄʱºo£¬unset()ºo£¬ÈËÀe¿ªµÄʱºo£¬Òª°ÑµçÊÓ¹ØÁË £¬Ò²¾ÍÊÇÊÍÅÕ¼ÓõĴae´¢¿Õ¼a¡£¶ÔÕa²¿ÖÄÚÈݸÐÐËȤµÄ»°Ò²¿ÉÒÔ¿´Ò»Ï¡¶php µÝ¹eº¯ÊýµÄÈýÖÖʵÏÖ*½Ê½¡*¡£
¡¡¡¡ºÃµÄ£¬»Ø¹eÖ÷Ìa¡£ unset($test1£(C)¡¡ºo£¬¡¡ÔÀ´µÄ¶ÔÏo»¹ÔÚ¡£µ±Êa³o*Ö¸iÏߺo£¬½Å±¾Ö´ÐÐÍe±Ï£¬µ÷ÓÃÎo¹¹º¯Êý¡£ ÒoΪ¶ÔÏoÖ»ÓÐÒ»¸o£¬µ÷ÓÃÎo¹¹º¯ÊýÒ²Ö»µ÷ÓÃÒ»´Î¡£Êa³oÈçÉϽa¹uÒ²¾ÍÀiËuÓ¦µ±¡£
¡¡¡¡ÆaËu¼¸¸oÏa¹ØµÄÓÐÒa˼µÄÎÊÌa£ºÔÚ³ÌÐoÖе÷ÓÃÎo¹¹º¯ÊýµÄ½¨»¹Óкܶa¡£ÎÞÂÛÊÇÉeÖöÔÏoΪnull,»¹ÊÇfalse,ÆaÓaµÄ¶ÔÏoÒÀ¾É²»ÊÜÓ°Ïi¡£ÕaºÍÆÕͨ±aÁ¿»¹ÊÇÓÐÇø±ðµÄ¡£(unset()º¯ÊýµÄЧ¹uÊÇÒ»ÑuµÄ)¡£ÓÐÐËȤµÄ»°¿ÉÒÔÊÔÊÔ¡£
¡¡¡¡ÁiÍa˵һ¸o±È½Ï‡aµÄÊÂÇe£ºÎÒÃǶ¼ÖªµÀ¹¹Ôiº¯Êý¿ÉÒÔʹÓÃ__construct()£¬È´ºoÊÓÁËͬÃu¹¹Ôiº¯Êý¡£ËuÒÔ£¬´o¼Ò»¹ÊÇÁoÐÄһϡ£
×iºoÎÒÃÇÀ´¿´¸oÀý×Ó
<?php
/*
* Created on 2009-11-18
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
class student{
//ÊoÐÔ
private $no;
private $name;
private $gender;
private $age;
private static $count=0;
function __construct($pname)
{
$this->name = $pname;
self::$count++;
}
function __destruct()
{
self::$count--;
}
static function get_count()
{
return self::$count;
}
}
$s1=new student("Tom");
print(student::get_count());
$s2=new student("jerry");
print(student::get_count());
$s1=NULL;
print(student::get_count());
$s2=NULL;
print(student::get_count());
?>
ÉÏÃaeÕa¶Î´uÂe¾ÍÊÇPHP5Îo¹¹º¯ÊýµÄ¾ßÌaʹÓý¨£¬Ï£Íu¶Ô´o¼ÒÓÐËu°iÖu¡£