欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > php >内容正文

php

php静态变量的销毁

发布时间:2024/9/5 php 34 豆豆
生活随笔 收集整理的这篇文章主要介绍了 php静态变量的销毁 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

什么都不说,先上代码:

1 public function _childrenids($data,$cate_id,$clear=false) 2 { 3 static $arr = array(); 4 if ($clear) 5 { 6 $arr = array(); 7 } 8 foreach ($data as $k => $v) 9 { 10 if($v['pid'] == $cate_id) 11 { 12 $arr[] = $v['id']; 13 $this -> _childrenids($data,$v['id']); 14 } 15 } 16 return $arr; 17 }

在代码里面,我们知道了 $arr是静态变量。

但是,一般的注销是不能注销静态变量的:

来源:http://php.net/manual/zh/function.unset.php

所以,我们要注销一个静态变量,只能通过重新定义的方式进行清空!!!

转载于:https://www.cnblogs.com/laijinquan/p/10197880.html

总结

以上是生活随笔为你收集整理的php静态变量的销毁的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。