preprocess function call - $vars[node_title] does not work as a parameter, while $vars['node-title'] does I am writing a preprocess function. I provided a linkIt function that does the linking for me: 

function linkIt($what, $where) {


return '&lt;a href="' . $where . '" class="' . $what . '.-preprocess-field preprocess-field"&gt;' . t($what) . '&lt;/a&gt;';


}
If I call it this way: 

$test= linkIt('XXX', $vars[node_url]);


it produces a Drupal error 'Use of undefined constant node_url - assumed 'node_url''. If I call it  

$test= linkIt('XXX', $vars['node_url']);


with quotes around node_urlit works fine.
The former syntax is properly evaluated if I do not pass it as a function paramter, for example in  

$vars['opis'] = '&lt;a href="' . $vars[node_url] . '" class="opis-preprocess-field"&gt;' . t('XXX') . '&lt;/a&gt;'


Why is it so?
Always use quotes around a string literal array index. For example, $foo['bar'] is correct, while $foo[bar] is not. But why? It is common to encounter this kind of syntax in old scripts:


This is wrong, but it works. The reason is that this code has an undefined constant (bar) rather than a string ('bar' - notice the quotes). PHP may in the future define constants which, unfortunately for such code, have the same name. It works because PHP automatically converts a bare string (an unquoted string which does not correspond to any known symbol) into a string which contains the bare string. For instance, if there is no defined constant named bar, then PHP will substitute in the string 'bar' and use that.

See PHP:Arrays - Manual Chapter "Array do's and don'ts"