QuickHashIntStringHash::exists()

检查一个键是否存在于QuickHashIntStringHash对象中

首字母:Q

函数名称:QuickHashIntStringHash::exists()

适用版本:PHP 5 >= 5.4.0, PHP 7, PECL quickhash >= 1.0.0

函数描述:检查一个键是否存在于QuickHashIntStringHash对象中。

用法: bool QuickHashIntStringHash::exists ( mixed $key )

参数:

  • $key:要检查的键。可以是整数或字符串。

返回值: 如果键存在于QuickHashIntStringHash对象中,则返回true;如果键不存在,则返回false。

示例:

// 创建一个QuickHashIntStringHash对象
$hash = new QuickHashIntStringHash();
// 添加一些键值对
$hash->add(1, 'apple');
$hash->add(2, 'banana');
$hash->add(3, 'cherry');
// 检查键是否存在
if ($hash->exists(2)) {
 echo "键存在";
} else {
 echo "键不存在";
}
// 输出:键存在

在上面的示例中,我们创建了一个QuickHashIntStringHash对象,并添加了一些键值对。然后,我们使用exists()函数检查键2是否存在于对象中。由于键2存在,所以输出"键存在"。

同首字母函数