PHP 文件打开/读取
PHP Open File - fopen() 打开文件的更好的方法是通过 fopen() 函数。此函数为您提供比 readfile() 函数更多的选项。 在课程中,我们将使用文本文件 "webdictionary.txt": AJAX = Asynchronous JavaScript and XML CSS = Cascading Style Sheets HTML = Hyper Text Markup Language PHP = PHP Hypertext Preprocessor SQL = Structured Query Language SVG = Scalable Vector Graphics XML = EXtensible Markup Language fopen() 的第一个参数包含被打开的文件名,第二个参数规定打开文件的模式。如果 fopen() 函数未能打开指定的文件,下面的例子会生成一段消息: 实例 <?php $myfile = fopen("webdictionary.txt", "r") or die("Unable to open file!"); echo fread($myfile,filesize("webdictionary.txt")); fclose($myfile); ?> 提示: 我们接下来将学习 fread() 以及