doujunchi1238 2010-02-21 12:08
浏览 134

PHP函数帮助

I've written this piece of code, which outputs the profile_display_fields for the $USER:

$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>';
            }
        }

Here is the function I'm using:

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());
                    }
                }
            }
        }
    }
}

What I'm looking to do is try some var_dumps to output the correct data.

However can anyone help me identify the variables?

  • 写回答

1条回答 默认 最新

  • duanpo1821 2010-02-21 12:21
    关注

    In your function you are not returning any value but above that in your code, you have assigned a variable to this function:

    $appearance = profile_display_fields($USER->id);
    

    You need to return some variable/data from the function and that is the one to be var dumped.

    I suppose you are using the print_row to print the data, not returning the response to be used out of the function.

    评论

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错