PHP数组...什么是/是一个空架的意思(S)? [英] PHP arrays... What is/are the meaning(s) of an empty bracket?

查看:119
本文介绍了PHP数组...什么是/是一个空架的意思(S)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一些例如code,看起来像这样运行:

I ran across some example code that looks like this:

$form['#submit'][] = 'annotate_admin_settings_submit';

为什么会出现['#submit']是空与里面什么都没有后支架?这意味着什么?谁能给我一个例子吗?一般情况下(从我的理解,这可能是错误的)是阵列具有键和在这种情况下的$形式数组键'#submit'等于'annotate_admin_settings_submit但什么是与第二组括号内的交易。我见过的例子,一个数组可能看起来像:

Why is there a bracket after ['#submit'] that is empty with nothing inside? What does this imply? Can anyone give me an example? Normally (from my understanding which is probably wrong) is that arrays have keys and in this case the the $form array key '#submit' is equal to 'annotate_admin_settings_submit' but what is the deal with the second set of brackets. I've seen examples where an array might look like:

$表['行动'] ['#类型'] ='行动';

我知道这是关于PHP的一个非常基本的问题,但我碰到这个问题跑,而学习的Drupal在Drupal社区,所以希望有人能澄清这个问题了,我沉迷在。

I know this is a very basic question about php in general but I ran across this question while learning Drupal so hopefully someone in the Drupal community can clarify this question that I'm obsessing over.

推荐答案

当你说 $表['行动'] ['#类型'] ='行动' ,它分配一个值 $表['行动'] ['#类型'] ,但是当你说 $表['#提交 ] [] ='annotate_admin_settings_submit'; ,如果 $表['#提交'] 是一个数组,其追加 annotate_admin_settings_submit来结束它,如果它是空的,它会随着这是一个单一的元素的数组'annotate_admin_settings_submit

When you say $form['actions']['#type'] = 'actions', it assigns a value to $form['actions']['#type'], but when you say $form['#submit'][] = 'annotate_admin_settings_submit';, if $form['#submit'] is an array, it appends 'annotate_admin_settings_submit' to the end of it, and if it's empty, it will be an array with one single element that is 'annotate_admin_settings_submit'.

这篇关于PHP数组...什么是/是一个空架的意思(S)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆