PHP wrapper functions
Functions that are wrappers or custom implementations of PHP functions.
Certain PHP functions should not be used in Drupal. Instead, Drupal's replacement functions should be used.
For example, for improved or more secure UTF8-handling, or RFC-compliant handling of URLs in Drupal.
For ease of use and memorizing, all these wrapper functions use the same name as the original PHP function, but prefixed with "drupal_". Beware, however, that not all wrapper functions support the same arguments as the original functions.
You should always use these wrapper functions in your code.
Wrong:
$my_substring = substr($original_string, 0, 5);
Correct:
$my_substring = drupal_substr($original_string, 0, 5);
File
- drupal-7.x/
includes/ common.inc, line 11 - Common functions that many Drupal modules will need to reference.
Functions
Name | Location | Description |
---|---|---|
drupal_basename |
drupal-7.x/ |
Gets the filename from a given path. |
drupal_chmod |
drupal-7.x/ |
Sets the permissions on a file or directory. |
drupal_dirname |
drupal-7.x/ |
Gets the name of the directory from a given path. |
drupal_http_build_query |
drupal-7.x/ |
Parses an array into a valid, rawurlencoded query string. |
drupal_json_decode |
drupal-7.x/ |
Converts an HTML-safe JSON string into its PHP equivalent. |
drupal_json_encode |
drupal-7.x/ |
Converts a PHP variable into its JavaScript equivalent. |
drupal_mkdir |
drupal-7.x/ |
Creates a directory using Drupal's default mode. |
drupal_move_uploaded_file |
drupal-7.x/ |
Moves an uploaded file to a new location. |
drupal_parse_url |
drupal-7.x/ |
Parses a system URL string into an associative array suitable for url(). |
drupal_realpath |
drupal-7.x/ |
Resolves the absolute filepath of a local URI or filepath. |
drupal_register_shutdown_function |
drupal-7.x/ |
Registers a function for execution on shutdown. |
drupal_rmdir |
drupal-7.x/ |
Removes a directory. |
drupal_session_regenerate |
drupal-7.x/ |
Called when an anonymous user becomes authenticated or vice-versa. |
drupal_session_start |
drupal-7.x/ |
Starts a session forcefully, preserving already set session data. |
drupal_set_time_limit |
drupal-7.x/ |
Attempts to set the PHP maximum execution time. |
drupal_strlen |
drupal-7.x/ |
Counts the number of characters in a UTF-8 string. |
drupal_strtolower |
drupal-7.x/ |
Lowercase a UTF-8 string. |
drupal_strtoupper |
drupal-7.x/ |
Uppercase a UTF-8 string. |
drupal_substr |
drupal-7.x/ |
Cuts off a piece of a string based on character indices and counts. |
drupal_tempnam |
drupal-7.x/ |
Creates a file with a unique filename in the specified directory. |
drupal_ucfirst |
drupal-7.x/ |
Capitalizes the first letter of a UTF-8 string. |
drupal_unlink |
drupal-7.x/ |
Deletes a file. |
drupal_xml_parser_create |
drupal-7.x/ |
Prepares a new XML parser. |
php_eval |
drupal-7.x/ |
Evaluates a string of PHP code. |