以下是一个使用PHP访问本地文件系统的实例,包括读取文件、写入文件以及列出目录内容等功能。
实例1:读取本地文件内容
```php

// 定义文件路径
$file_path = 'example.txt';
// 检查文件是否存在
if (file_exists($file_path)) {
// 读取文件内容
$content = file_get_contents($file_path);
echo "
以下是一个使用PHP访问本地文件系统的实例,包括读取文件、写入文件以及列出目录内容等功能。
```php

// 定义文件路径
$file_path = 'example.txt';
// 检查文件是否存在
if (file_exists($file_path)) {
// 读取文件内容
$content = file_get_contents($file_path);
echo "