常用函数-delete_option()

0条评论

说明

这是一种从选项数据库表中删除某一有名称的选项/值对的安全方法。

用法

<?php delete_option($name); ?>  

示例

下面是一个一次性删除一个或多个选项并验证结果的简单方法:

<?php
function deleteOptions()
{
	$args = func_get_args();
	$num = count($args);

	if ($num == 1) {
		return (delete_option($args[0]) ? TRUE : FALSE);
	}
	elseif (count($args) > 1)
	{
		foreach ($args as $option) {
			if ( ! delete_option($option))
				return FALSE;
		}
		return TRUE;
	}
	return FALSE;
}

if (deleteOptions('is_installed', 'my_plugin_version', 'my_option'))
   echo 'Options have been deleted!';
else
   echo 'An error has occurred while trying to delete the options from database!';
?>

用法

<?php delete_option("myhack_extraction_length"); ?>  

参数

$name

(字符串)(必需)将要删除的选项的名称。在Option Reference中列出了一系列有效默认选项。

默认值:None

返回的值

若成功删除选项,返回TRUE,否则返回FALSE

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许HTML标签:<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • 自动断行和分段。

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.