Php 在类内的数组中填充数组值

Php 在类内的数组中填充数组值,php,wordpress,class,Php,Wordpress,Class,我有一个关于php的例子 class My_Example_List_Table extends WP_List_Table { var $example_data = array( array( 'ID' => 1,'fullname' => 'Quarter Share', 'email' => 'Nathan Lowell', 'driver' => '978-0982514542' , 'm

我有一个关于php的例子

class My_Example_List_Table extends WP_List_Table {

    var $example_data = array(
            array( 'ID' => 1,'fullname' => 'Quarter Share', 'email' => 'Nathan Lowell', 
                   'driver' => '978-0982514542' , 'medic' => '0000'),
            array( 'ID' => 2, 'fullname' => '7th Son: Descent','email' => 'J. C. Hutchins',
                   'driver' => '0312384378' , 'medic' => '0000'),
            array( 'ID' => 3, 'fullname' => 'Shadowmagic', 'email' => 'John Lenahan',
                   'driver' => '978-1905548927' , 'medic' => '0000'),
            array( 'ID' => 4, 'fullname' => 'The Crown Conspiracy', 'email' => 'Michael J. Sullivan',
                   'driver' => '978-0979621130' , 'medic' => '0000'),
            array( 'ID' => 5, 'fullname'     => 'Max Quick: The Pocket and the Pendant', 'email'    => 'Mark Jeffrey',
                   'driver' => '978-0061988929' , 'medic' => '0000'),
            array('ID' => 6, 'fullname' => 'Jack Wakes Up: A Novel', 'email' => 'Seth Harwood',
                  'driver' => '978-0307454355' , 'medic' => '0000')
        );
我要做的是从数据库填充数组,所以我这样做:

function getContactAttachmentList(){
    $users = get_users( 'role=subscriber' );

    $data = array();
    foreach ($users as $key) {

        $data[] = array( 
            'ID' => $key->ID,
            'fullname' => get_user_meta( $key->ID, 'first_name', true ).' '.get_user_meta( $key->ID, 'last_name', true ), 
            'email' => esc_html( $key->user_email ), 
            'driver' => get_user_meta( $key->ID, 'drivers', true ), 
            'medic' => get_user_meta( $key->ID, 'medics', true )
            );
    }

    return $data;
}
现在我有了这个代码:

class My_Example_List_Table extends WP_List_Table {

        var $example_data = getContactAttachmentList();
问题是我在那行中遇到了这个错误:

分析错误:语法错误,意外的“(”,应为“,”或“;”


有人对此有想法吗?提前谢谢

可能的重复我不这么认为..我担心数组中的设置
var$example\u data
使用
public function\uu-construct(){$this->example\u data==getContactAttachmentList();}
同样,来自php文档-谢谢sean:)它可以工作!