How is the callback function php curl CURLOPT_READFUNCTION used?

in the process of uploading files using curl, I see CURLOPT_READFUNCTION as a callback function. I don"t quite understand how to use it. Officials have not found a use case

.
Apr.01,2021

$ch = curl_init('http://www.yourapi.com/');
curl_setopt_array($ch, array(
    CURLOPT_HEADER => false,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_INFILESIZE => 1,
    CURLOPT_READFUNCTION => 'curl_read'
));
curl_exec($ch);
curl_close($ch);
function curl_read($ch, $fp, $len) {
    var_dump($fp);
    exit;
}
Menu