1
我寫這一段代碼,這爲$ USER輸出profile_display_fields
:PHP函數幫助
$appearance = profile_display_fields($USER->id);
if (empty($appearance)) {
//Do nothing
} else {
foreach ($appearance as $c) {
$custom .= '<a href=\''.$CFG->wwwroot.'/course/view.php?id='.$c->id.'\'>'.$c->fullname.'</a>';
}
}
這裏是我使用的功能:
function profile_display_fields($userid) {
global $CFG, $USER;
if ($categories = get_records_select('user_info_category', '', 'sortorder ASC')) {
foreach ($categories as $category) {
if ($fields = get_records_select('user_info_field', "categoryid=$category->id", 'sortorder ASC')) {
foreach ($fields as $field) {
require_once($CFG->dirroot.'/user/profile/field/'.$field->datatype.'/field.class.php');
$newfield = 'profile_field_'.$field->datatype;
$formfield = new $newfield($field->id, $userid);
if ($formfield->is_visible() and !$formfield->is_empty()) {
print_row(s($formfield->field->name.':'), $formfield->display_data());
}
}
}
}
}
}
我」什麼m想要做的是嘗試一些var_dump
s輸出正確的數據。
然而誰能幫我鑑定的變量?
你想要什麼的var_dump?哪個變量? – Sarfraz 2010-02-21 12:16:37
我知道var_dump($ something);但哪些是PHP上面的變量? – CLiown 2010-02-21 12:18:04
正如你所編寫的代碼,你應該知道'$ something' s爲變量... – 2010-02-21 12:19:17