WordPress开发者和主题制作者的搜索引擎



wp_unique_id ›

Since5.0.3
已弃用n/a
wp_unique_id ( $prefix = '' )
参数:
  • (string) $prefix Prefix for the returned ID.
    Required: No
    默认: (empty)
返回:
  • (string) Unique ID.
定义在:
文档:

Get unique ID.

This is a PHP implementation of Underscore's uniqueId method. A static variable contains an integer that is incremented with each call. This number is returned with the optional prefix. As such the returned value is not universally unique, but it is unique across the life of the PHP process.



源码

function wp_unique_id( $prefix = '' ) {
	static $id_counter = 0;
	return $prefix . (string) ++$id_counter;
}