Home >Backend Development >PHP Tutorial >How to read PDF files online with PHP, _PHP tutorial
The example in this article describes how to use PHP to read PDF files online. Share it with everyone for your reference. The specific implementation method is as follows:
<?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');
I hope this article will be helpful to everyone’s PHP programming design.