Xử lý file trong php

PHP hỗ trợ các function để tạo, đọc, viết file

Ví dụ về đọc file

Tạo 1 file text.txt với nội dung sau:

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

File main.php:

<!DOCTYPE html>
<html>
<body>

<?php
echo readfile("text.txt");
?>

</body>
</html>

Kết quả

 

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 Language236