关联数组(PHP)(Associative array (PHP))

编程入门 行业动态 更新时间:2024-10-26 07:35:30
关联数组(PHP)(Associative array (PHP))

当它说:(它来自drupal的hook_block_view代码时)我不知道它是什么意思

$ block ['content'] = array('#theme'=>'node_recent_block','#node'=> $ nodes,);

我知道$ block ['content']是一个关联数组,我也知道$ node是Full节点对象,包含可能不安全的数据。但是关于#theme,#node和'node_recent_block。 有人可以告诉我他们的意思。

我搜索了很多但是我没有发现当一个键的名字前面有一个#时它是什么意思。 谢谢

I do not know what does it mean when it says: (it is from hook_block_view code for drupal)

$block['content'] = array( '#theme' => 'node_recent_block', '#nodes' => $nodes, );

I know $block['content'] is an associative array, also I know that $node is Full node object, Contains data that may not be safe.But about #theme, #nodes and 'node_recent_block. Can someone please tell me what do they mean.

I searched a lot but I did not find out what does it mean when there is a # before name of a key. Thank you

最满意答案

$ block是一个关联数组,其中元素“content”也是一个关联数组。

另一种定义方法是:

$block = array( 'content' => array( '#theme' => 'node_recent_block', '#nodes' => $nodes, ), );

在关联数组内部=>是一个赋值。

'content'是一个数组,其中'#theme'='node_recent_block'和'#nodes'= $ nodes

编辑:

您也可以像这样分配值:

$block['content']['#theme'] = 'node_recent_block'; $block['content']['#nodes'] = $nodes;

$block is an associative array, in which the element "content" is also an associative array.

Another way to define this would be:

$block = array( 'content' => array( '#theme' => 'node_recent_block', '#nodes' => $nodes, ), );

Inside an associative array => is an assignment.

'content' is an array where '#theme' = 'node_recent_block' and '#nodes' = $nodes

Edit:

You could also assign the values like this:

$block['content']['#theme'] = 'node_recent_block'; $block['content']['#nodes'] = $nodes;

更多推荐

本文发布于:2023-07-16 07:44:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1125526.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   PHP   array   Associative

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!