PHP5 面向对象程序设计

2019-04-10 23:14:55刘景俊


例如:


<?php  
class Person{  
}  
function sendEmailTo(){  
}  

$haohappy = new Person( );    
// 建立一个新对象:  引用计数    Reference count = 1  
$haohappy2 = $haohappy;        
// 通过引用复制:  Reference count = 2  
unset($haohappy);            
// 删除一个引用: Reference count = 1  
sendEmailTo($haohappy2);       
// 通过引用传递对象:    
// 在函数执行期间:  
//  Reference count = 2  
// 执行结束后:  
// Reference count = 1  

unset($haohappy2);            
// 删除引用: Reference count = 0 自动释放内存空间  

?> 

相关文章 大家在看