PHP-将数组定义为函数调用的一部分是不好的做法吗?

使用wordpress并查看代码示例,我已经看到了使用数组和函数的两种不同方式:

1.首先定义数组,然后将其作为参数传递给函数

$args = array(
    'name' => 'Home right sidebar',
    'id' => 'home_right_1',
    'before_widget' => '<div>',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="rounded">',
    'after_title' => '</h2>', 
 );
register_sidebar( $args );

2.将数组定义为函数调用的一部分

register_sidebar( array(
    'name' => 'Home right sidebar',
    'id' => 'home_right_1',
    'before_widget' => '<div>',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="rounded">',
    'after_title' => '</h2>', 
 ) );

将数组定义为函数调用(#2)的一部分是不好的做法,还是它是一种样式选择?

如果不好的做法,为什么呢?

解决方法:

不,这不是坏习惯.

如果要重复使用阵列,则必须选择第一个可能性.否则,选择取决于您.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...