文件上传使用到的函数

使用到的函数:

①header():

  header(‘Location:localhost/answer_app/test.php’),跳转到指定页面:test.php


②pathinfo():
  以数组或字符串的形式返回关于文件路径的信息,返回的数组元素如下:
  [dirname]:返回文件路径中的目录部分;
  [basename]:返回文件路径中文件名的部分;
  [extension]:返回文件路径中文件的类型的部分
实例 1
<?php
print_r(pathinfo("/testweb/test.txt"));
?>
上面的代码将输出:
Array
(
[dirname] => /testweb
[basename] => test.txt
[extension] => txt
)

实例 2
<?php
var_dump(pathinfo("/testweb/test.txt",PATHINFO_DIRNAME));
var_dump(pathinfo("/testweb/test.txt",PATHINFO_BASENAME));
var_dump(pathinfo("/testweb/test.txt",PATHINFO_EXTENSION));
?>
上面的代码将输出:
string(8)"/testweb"
string(8)"test.txt"
string(3)"txt"

③in_array():

  搜索数组中是否存在指定的值。

  用法:in_array(search,array,type)

   search:必需。规定要在数组搜索的值;

   array:必需。规定要搜索的数组;

   type:可选。如果设置该参数为 true,则检查搜索的数据与数组的值的类型是否相同

  注释:如果 search 参数是字符串,且 type 参数设置为 true,则搜索区分大小写。

④is_dir()、mkdir():

  is_dir():判断指定的文件名是否是一个目录

  mkdir():mkdir()函数创建目录。若成功,则返回 true,否则返回 false

    语法:mkdir(path,mode,recursive,context)

path 必需。规定要创建的目录的名称。
mode 可选。规定权限。默认是 0777。
recursive 可选。规定是否设置递归模式。
context 可选。规定文件句柄的环境。Context 是可修改流的行为的一套选项。

 

 

 

 ⑤date():

  把时间戳格式化为更易读的日期和时间。示例:date('Y-m-d H:i:s',time());

原文地址:https://www.cnblogs.com/jytblog/p/7272818.html