PHP wrapper functions
Same name and namespace in other branches
- 9 core/includes/common.inc \php_wrappers
- 8.9.x core/includes/common.inc \php_wrappers
- 10 core/includes/common.inc \php_wrappers
- 11.x core/includes/common.inc \php_wrappers
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
-
includes/
common.inc, line 11
Functions
Title | File name Sort descending | Summary |
---|---|---|
drupal_setcookie | includes/ |
Drupal's wrapper around PHP's setcookie() function. |
drupal_register_shutdown_function | includes/ |
Registers a function for execution on shutdown. |
drupal_json_decode | includes/ |
Converts an HTML-safe JSON string into its PHP equivalent. |
drupal_json_encode | includes/ |
Converts a PHP variable into its JavaScript equivalent. |
drupal_set_time_limit | includes/ |
Attempts to set the PHP maximum execution time. |
drupal_parse_url | includes/ |
Parses a URL string into its path, query, and fragment components. |
drupal_http_build_query | includes/ |
Parses an array into a valid, rawurlencoded query string. |
drupal_move_uploaded_file | includes/ |
Moves an uploaded file to a new location. |
drupal_tempnam | includes/ |
Creates a file with a unique filename in the specified directory. |
drupal_rmdir | includes/ |
Removes a directory. |
drupal_mkdir | includes/ |
Creates a directory, optionally creating missing components in the path to the directory. |
drupal_basename | includes/ |
Gets the filename from a given path. |
drupal_dirname | includes/ |
Gets the name of the directory from a given path. |
drupal_realpath | includes/ |
Resolves the absolute filepath of a local URI or filepath. |
drupal_unlink | includes/ |
Deletes a file. |
drupal_chmod | includes/ |
Sets the permissions on a file or directory. |
drupal_session_start | includes/ |
Starts a session forcefully, preserving already set session data. |
drupal_session_regenerate | includes/ |
Called when an anonymous user becomes authenticated or vice-versa. |
drupal_xml_parser_create | includes/ |
Prepares a new XML parser. |
drupal_strlen | includes/ |
Counts the number of characters in a UTF-8 string. |
drupal_strtoupper | includes/ |
Uppercase a UTF-8 string. |
drupal_strtolower | includes/ |
Lowercase a UTF-8 string. |
drupal_ucfirst | includes/ |
Capitalizes the first letter of a UTF-8 string. |
drupal_substr | includes/ |
Cuts off a piece of a string based on character indices and counts. |
php_eval | modules/ |
Evaluates a string of PHP code. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.