get_transient()获取某个保留在数据库的临时值

目录

描述

Get the value of a transient.

If the transient does not exist or does not have a value, then the return value will be false.

get_transient() 描述

用法

<?php get_transient$transient ); ?>

get_transient() 用法

参数

$transient

(string) (必填) Unique transient name (this should be 45 characters or less in length. NOTE: if using a site transient, it should be 40 characters or less in length). Expected to not be SQL-escaped.

默认值: None

get_transient() 参数

返回值

(mixed) 

Value of transient. If the transient does not exist, does not have a value, or has expired, then get_transient will return false. This should be checked using the identity operator ( === ) instead of the normal equality operator, because an integer value of zero (or other "empty" data) could be the data you're wanting to store. Because of this "false" value, transients should not be used to hold plain boolean values. Put them into an array or convert them to integers instead.

get_transient() 返回值

示例

Example of using get_transient, set_transient and WP_Query

Add WP_DEBUG in the conditional statement if you always want live data during development stage

get_transient() 示例

历史

添加于 版本: 2.8

get_transient() 历史

源文件

get_transient() 函数的代码位于 wp-includes/option.php.

get_transient() 源文件

相关