Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_unique_id ›

Seit4.9.9
Veraltetn/v
wp_unique_id ( $prefix = '' )
Parameter:
  • (string) $prefix Prefix for the returned ID.
    Erforderlich: Nein
    Standard: (leer)
Gibt zurück:
  • (string) Unique ID.
Definiert in:
Codex:

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.



Quellcode

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