What's wrong with the way I use variables in my function? I have a function that looks like this:

function mymodule_privatemsg_message_validate($message) {
  $uid = $vars['message']-&gt;author-&gt;uid;

  //if root or help user, message should always go through regardless of length
  if ($uid !== '1') {
    if ($uid !== '3') {

      if (empty($message-&gt;thread_id) &amp;&amp; strlen($message-&gt;body) &lt; 200 ) {
    form_set_error('[body][value]', t('My custom message.'));
      }
    }
  }
}


However, I received a comment that "As side note, you are using $vars, but that variable has not been initialized from the function, nor is a function's parameter."  I don't understand what this means or what I'm doing wrong.  Could someone explain this to me?
For a variable to be available in the scope of a function, it needs to have been initialised (or it needs to have been initialised in the global scope and imported into the local function using global).

At the moment there's nothing declaring or passing the $vars variable in...it hasn't been initialised, thus you get the warning.

You're passing a variable to the function called $message, which suggests your code should be:

$uid = $message-&gt;author-&gt;uid;


The confusion with $vars/$variables might be caused by the fact that it's sort of the standard name for the only argument passed to theme functions, e.g.

function MYTHEME_preprocess_node(&amp;$vars) {
  // Use $vars