Utility classes and functions

Overview of utility classes and functions for developers.

Drupal provides developers with a variety of utility functions that make it easier and more efficient to perform tasks that are either really common, tedious, or difficult. Utility functions help to reduce code duplication and should be used in place of one-off code whenever possible.

See also


File interface



PHP wrapper functions

Sanitization functions


Input validation


Namesort descending Location Description
Crypt drupal/core/lib/Drupal/Component/Utility/Crypt.php Utility class for cryptographically-secure string handling routines.
DiffArray drupal/core/lib/Drupal/Component/Utility/DiffArray.php Provides helpers to perform diffs on multi dimensional arrays.
Html drupal/core/lib/Drupal/Component/Utility/Html.php Provides DOMDocument helpers for parsing and serializing HTML strings.
Image drupal/core/lib/Drupal/Component/Utility/Image.php Provides helpers to operate on images.
NestedArray drupal/core/lib/Drupal/Component/Utility/NestedArray.php Provides helpers to perform operations on nested arrays and array keys of variable depth.
Number drupal/core/lib/Drupal/Component/Utility/Number.php Provides helper methods for manipulating numbers.
OpCodeCache drupal/core/lib/Drupal/Component/Utility/OpCodeCache.php Provides helpers to handle PHP opcode caches.
Random drupal/core/lib/Drupal/Component/Utility/Random.php Defines a utility class for creating random data.
Settings drupal/core/lib/Drupal/Core/Site/Settings.php Read only settings that are initialized with the class.
SortArray drupal/core/lib/Drupal/Component/Utility/SortArray.php Provides generic array sorting helper methods.
String drupal/core/lib/Drupal/Component/Utility/String.php Provides helpers to operate on strings.
Tags drupal/core/lib/Drupal/Component/Utility/Tags.php Defines a class that can explode and implode tags.
Timer drupal/core/lib/Drupal/Component/Utility/Timer.php Provides helpers to use timers throughout a request.
Unicode drupal/core/lib/Drupal/Component/Utility/Unicode.php Provides Unicode-related conversions and operations.
UrlHelper drupal/core/lib/Drupal/Component/Utility/UrlHelper.php Helper class URL based methods.
UserAgent drupal/core/lib/Drupal/Component/Utility/UserAgent.php Provides user agent related utility functions.
Variable drupal/core/lib/Drupal/Component/Utility/Variable.php Provides helpers for dealing with variables.
Xss drupal/core/lib/Drupal/Component/Utility/Xss.php Provides helper to filter for cross-site scripting.


drupal/core/modules/system/core.api.php, line 1543
Documentation landing page and topics, plus core library hooks.