How can I check if something was print in the browser? I've tried headers_sent but it's for headers... If nothing was printed i want to download a file:
public function download() {
$file = null;
$line = null;
if(headers_sent($file, $line)) {
/* generic exception... change that... */
throw new Exception('Headers was sent before in file ' . $file . ', line #' . $line);
}
header('Content-Description: File Transfer');
header('Content-Type: ' . $this->mime);
header('Content-Disposition: attachment; filename=' . $this->name);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . $this->size);
readfile($this->path);
Teşekkür ederim.