Follow us on Twitter!
Syndicate content
Login - Register - Latests submissions

code

When developping a module, we often use some commonly used PHP functions. As you may not know Drupal provides some overrides for these functions. They are often related to strings, they have the same name as their PHP native equivalent except that they are prefixed with drupal_. Here is a list of PHP functions you should replace with its Drupal equivalent:

  • Replace strlen() with drupal_strlen()
  • Replace strtoupper() with drupal_strtoupper()
  • Replace strtolower() with drupal_strtolower()
  • Replace ucfirst() with drupal_ucfirst()
  • Replace substr() with drupal_substr()
  • Replace eval() with drupal_eval()
  • Replace clone with drupal_clone()

For more on this, you should read includes/unicode.inc and includes/common.inc.

If you are working with a code repository (like svn, git, etc.) you might have found it useful to set up a cron job that regularly runs a script that in turn triggers the update of your code on the server. While this is nice while developing it may be disastrous in production environment!

Make sure to disable any automated update of your code before going live.

fp