使用过滤器时如何输出变量


How to output variable when use filter?

我想检查一下$file

我在这里发现了类似的问题,但在这种情况下不起作用。https://wordpress.stackexchange.com/questions/51145/get-php-variable-from-functions-php-and-echo-it-in-theme-template-files

有人能帮帮我吗?或者给我一个关键字

WordPress functions.php

function wp_modify_uploaded_file_names($file) {
    $info = pathinfo($file['name']);
    $ext  = empty($info['extension']) ? '' : '.' . $info['extension'];
    $name = basename($file['name'], $ext);
    $file['name'] = uniqid() . $ext; // uniqid method
    print_r($file);
   return $file;
}
add_filter('wp_handle_upload_prefilter', 'wp_modify_uploaded_file_names', 1, 1);

单个参数$file表示$_FILES数组中的单个元素。可以通过$file['tmp_name']访问上传文件在服务器上存储的临时文件名