我在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();
问题是我在这行中遇到了这个错误:
Parse error: syntax error, unexpected '(', expecting ',' or ';'
有没有人对此有所了解?提前谢谢