首页 | 博客群 | 公社 | 专栏 | 论坛 | 图片 | 资讯 | 注册 | 帮助 | 博客联播 | 随机访问
客户端数据(GPC)的统一处理- -| 回首页 | 2004年索引 | - -合并数组的一个简单方法

删除变量时unset()和null的区别

                                      

当程序里不再使用某些大体积的变量时(如:数组或对象),我们有必要删除它们

第一种方法:$varname=null
第二种方法:unset($varname)

我一直都误以为它们的作用是相同的,直到这几天,我才发现了他们的区别。


代码:

<?php 

$a
= array(
    
'a' => 'a',
    
'b' => 'b'
);
$b = array(
    
'a' => 'a',
    
'b' => 'b'
);

$a['b'] = null;
unset(
$b['b']);

print(
'<pre>');
print_r($a);
print(
'<br />');
print_r($b);
print(
'</pre>');
?>
结果: Array ( [a] => a [b] => ) Array ( [a] => a )

【作者: phper】【访问统计:】【2004年11月4日 星期四 11:28】【注册】【打印

搜索

Google

Trackback

你可以使用这个链接引用该篇文章 http://publishblog.blogchina.com/blog/tb.b?diaryID=203266

回复

- 评论人:dasgwe   2008-05-29 12:52:27   

〈a href="www.aleabeauty.com/index.asp"〉精油〈/a〉
您了解〈a href="www.aleabeauty.com/index.asp"〉精油〈/a〉吗?他是〈a href="www.aleabeauty.com/index.asp"〉纯天然〈/a〉的〈a href="www.aleabeauty.com/index.asp"〉礼品〈/a〉里面的〈a href="www.aleabeauty.com/index.asp"〉精华露〈/a〉是〈a href="www.aleabeauty.com/index.asp"〉化妆品〈/a〉和〈a href="www.aleabeauty.com/index.asp"〉精细化工〈/a〉产品里的主要成分,而更多的被引用到了〈a href="www.aleabeauty.com/index.asp"〉汽车香水〈/a〉里。

- 评论人:dasgwe   2008-05-29 12:47:31   

〈a href="www.aleabeauty.com/index.asp"〉精油〈/a〉
您了解〈a href="www.aleabeauty.com/index.asp"〉精油〈/a〉吗?他是〈a href="www.aleabeauty.com/index.asp"〉纯天然〈/a〉的〈a href="www.aleabeauty.com/index.asp"〉礼品〈/a〉里面的〈a href="www.aleabeauty.com/index.asp"〉精华露〈/a〉是〈a href="www.aleabeauty.com/index.asp"〉化妆品〈/a〉和〈a href="www.aleabeauty.com/index.asp"〉精细化工〈/a〉产品里的主要成分,而更多的被引用到了〈a href="www.aleabeauty.com/index.asp"〉汽车香水〈/a〉里。

- 评论人:fadsf   2005-08-04 23:17:30   

〈a href="http://www.jxhb.cn" target="_blank"〉空气净化〈/a〉
〈a href="http://www.magnet-toy.com" target="_blank"〉益智玩具〈/a〉
〈a href="http://www.lxyl.net" target="_blank"〉牵引床〈/a〉

〈a href="http://www.yourteam.com.cn" target="_blank"〉如新,如新团队〈/a〉
〈a href="http://www.delongfilm.com/cpzs.asp" target="_blank"〉防爆膜,汽车防爆膜〈/a〉
〈a href="http://www.delongfilm.com/cpzs.asp" target="_blank"〉防爆膜,汽车防爆膜〈/a〉
〈a href="http://www.shimingwan.com" target="_blank"〉失眠症〈/a〉

- 评论人:搜索引擎排名   2005-04-06 18:55:22   

[url=http://www.51jipiao.net/]机票[/url]
[url=http://www.51jipiao.net/]飞机票[/url]
[url=http://www.51jipiao.net/guonei.asp]打折机票[/url]
[url=http://www.51jipiao.net/guoji.asp]国际机票[/url]

- 评论人:手机铃声下载   2005-03-05 09:47:34   

还好我一直用unset,呵呵

- 评论人:匿名网友   2005-01-11 18:04:09   

halhlasdhf大师傅螺丝钉后

- 评论人:xhhy   2005-01-11 18:03:53   

你的观点正确,但没有考虑周全!
猜到我说那里了吗?
就是使用"&"传址的情况,你没有考虑进去
有时间多多交流:)

验证码:   
评论内容: