你可以通过测试来看是否一个变量被定义为特殊值void。
代码实例
if ( foobar == void ) // undefined运行效果

你可以使用【unset()】命令将变量回到未定义的状态。
代码实例
a == void; // true a=5; unset("a"); // 注意引号 a == void; // true运行效果

注意 unset() 命令接收的是字符串类型的变量名称,而不是变量。否则会出现如下异常。
本文转自 tongqiuyan 51CTO博客,原文链接:http://blog.51cto.com/tongqiuyan/767005