Home > php教程 > php手册 > php unset()和null变量清除分析

php unset()和null变量清除分析

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-25 16:46:22
Original
1687 people have browsed it

unset ( mixed var [, mixed var [, ...]])

unset() 销毁指定的变量。注意在 php 3 中,unset() 将返回 true(实际上是整型值 1),而在 php 4 中,unset() 不再是一个真正的函数:它现在是一个语句,这样就没有了返回值,试图获取 unset() 的返回值将导致解析错误

null 字节是变量为空 $t = ''; 变量有值,不过是空,isset()是true.

null 常数是 $t = null; 变量没有值,连空都不是,isset()是false.

<?php  
$a = array(  
&#39;a&#39; => &#39;a&#39;,  
&#39;b&#39; => &#39;b&#39;  
);  
$b = array(  
&#39;a&#39; => &#39;a&#39;,  
&#39;b&#39; => &#39;b&#39;  
);  
$a[&#39;b&#39;] = null;  
unset($b[&#39;b&#39;]);  
print(&#39;<pre class="brush:php;toolbar:false">&#39;);  
print_r($a);  
print(&#39;<br />&#39;);  
print_r($b);  
print(&#39;
Copy after login
'); /*结果: array ( [a] => a [b] => ) array ( [a] => a )*/ ?>

 


本文地址:

转载随意,但请附上文章地址:-)

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
PHP-Datenerfassung?
From 1970-01-01 08:00:00
0
0
0
pemerolehan data php?
From 1970-01-01 08:00:00
0
0
0
PHP 데이터 수집?
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template