本文實例講述了PHP實現在線閱讀PDF文件的方法。分享給大家供大家參考。具體實現方法如下:
<?php
if(!function_exists('read_pdf')) {
function read_pdf($file) {
if(strtolower(substr(strrchr($file,'.'),1)) != 'pdf') {
echo '文件格式不對.';
return;
}
if(!file_exists($file)) {
echo '文件不存在';
return;
}
header('Content-type: application/pdf');
header('filename='.$file);
readfile($file);
}
}
read_pdf('Python_study.pdf');
希望本文所述對大家的php程序設計有所幫助。
新聞熱點
疑難解答