Blogger Information
Blog 23
fans 0
comment 1
visits 16015
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php基础实战-常用文件、目录操作函数的应用(2018年8月28日)
大白鲸的博客
Original
764 people have browsed it

作业1:

文件的上传实例

实例

<?php
/**
 * Created by PhpStorm.
 * User: 大白~鲸
 * Date: 2018-08-29
 * Time: 11:16
 */
/**文件操作步骤*/
//1.创建或打开一个本地文件
//2.以写文件打开文件:W
header('Content-type:text/html;charset=utf-8');

$dir = opendir('./Templates') or die('打开失败');
// $dir = opendir('./') or die('打开失败');  //.或./当前目录
while (false != ($file = readdir($dir))) {
    // print $file."<br>";
    // print nl2br($file."\n");

    if ($file != "." && $file != "..") {
        print $file."<br>";
    }
}
closedir($dir);

echo '<hr>';
echo __FILE__,'<br>';
echo '文件名: '.basename(__FILE__).'<br>';

//2.获取目录名
echo '目录名: '.dirname(__FILE__).'<br>';
//php5.3+推荐使用常量__DIR__代替dirname()
echo __DIR__, '<br>';
$pathinfo = pathinfo(__FILE__);
echo '目录名:', $pathinfo['dirname'],'<br>';
echo '文件名:', $pathinfo['basename'],'<br>';
echo '扩展名:', $pathinfo['extension'],'<br>';

$path = dirname(__FILE__).DIRECTORY_SEPARATOR.basename(__FILE__);
echo $path,'<br>';

var_dump($path==__FILE__);

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:qualified

Teacher's comments:再加点自己的总结就更完美了!
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post