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);
Name | Location | Description |
---|---|---|
php_eval |
drupal/ |
Evaluates a string of PHP code. |
drupal_xml_parser_create |
drupal/ |
Prepare a new XML parser. |
drupal_unlink |
drupal/ |
Deletes a file. |
drupal_ucfirst |
drupal/ |
Capitalize the first letter of a UTF-8 string. |
drupal_tempnam |
drupal/ |
Creates a file with a unique filename in the specified directory. |
drupal_substr |
drupal/ |
Cut off a piece of a string based on character indices and counts. Follows the same behavior as PHP's own substr() function. |
drupal_strtoupper |
drupal/ |
Uppercase a UTF-8 string. |
drupal_strtolower |
drupal/ |
Lowercase a UTF-8 string. |
drupal_strlen |
drupal/ |
Count the amount of characters in a UTF-8 string. This is less than or equal to the byte count. |
drupal_set_time_limit |
drupal/ |
Attempts to set the PHP maximum execution time. |
drupal_session_start |
drupal/ |
Forcefully starts a session, preserving already set session data. |
drupal_session_regenerate |
drupal/ |
Called when an anonymous user becomes authenticated or vice-versa. |
drupal_rmdir |
drupal/ |
Removes a directory. |
drupal_register_shutdown_function |
drupal/ |
Registers a function for execution on shutdown. |
drupal_realpath |
drupal/ |
Returns the absolute local filesystem path of a stream URI. |
drupal_parse_url |
drupal/ |
Parses a system URL string into an associative array suitable for url(). |
drupal_move_uploaded_file |
drupal/ |
Moves an uploaded file to a new location. |
drupal_mkdir |
drupal/ |
Creates a directory using Drupal's default mode. |
drupal_json_encode |
drupal/ |
Converts a PHP variable into its JavaScript equivalent. |
drupal_json_decode |
drupal/ |
Converts an HTML-safe JSON string into its PHP equivalent. |
drupal_http_build_query |
drupal/ |
Parses an array into a valid, rawurlencoded query string. |
drupal_dirname |
drupal/ |
Gets the name of the directory from a given path. |
drupal_chmod |
drupal/ |
Sets the permissions on a file or directory. |
drupal_basename |
drupal/ |
Gets the filename from a given path. |