【发布时间】:2013-06-21 00:04:32
【问题描述】:
我有一个变量$doctype,它是一个数组:
$doctype = array(
'news' => ('news'),
'documents' => ('documents'),
'forms' => ('forms'),
'other' => ('other'),
);
用作另一个数组的选项:
$form['doc_type'] = array(
'#title' => 'Document Type',
'#type' => 'radios',
'#options' => $doctype,
'#size' => '30',
'#required' => TRUE,
'#default_value' => $doctype['news'],
现在我正在尝试将当前值传递给另一个函数
我试过了:
form($form_state, &$doctype) {
但它显示为缺少参数
我想通过引用传递它,而不是作为返回(已经占用/不想解决它)
感谢任何帮助
【问题讨论】:
-
参数是否为引用由函数定义控制,而不是调用者。
-
如果您想避免不必要的复制,PHP 会为您解决这个问题。它使用写时复制,因此仅在函数修改参数时才进行复制。
标签: php arrays drupal pass-by-reference