zoukankan      html  css  js  c++  java
  • PHP文件操作函数

    $file=file_get_contents('url');直接将文件读入字符串中

    readfile('url')直接将文件显示在屏幕上,是一种保护文件和带宽防盗链的手段。

    fopen('url',params)返回文件句柄。

    处理小文件:$file_contents=fread($fp,filesize($locate));

    处理较大文件:while(!feof($fp)){$chunk=fgets($fp) ; echo $chunk } fclose($fp);

    //写入文件

    fwrite($fp,$line);

    file_exists()

    is_file()

    is_readable()

    is_writable()

    filemtime()

    fileatime()

    filesize()

    检查目录

    opendir() readdir() closedir()类似于fopen fread fclose

    如何在线显示php源码

    highlight_file()

    highlight_string()

    如何在文件中存储配置信息

    config.ini

    parse_ini_file()解析ini相同格式的文件

    parse_ini_file('config.ini',true);返回一个数组。

    一般来将不要把配置文件放在web根目录下,应该放在根目录之外,从而使黑客和google无法访问。若必须放,则一定要用htaccess文件中包含一条文件指令。或者加密。

    如何访问远程服务器上的文件。fopen('http://url','r');

    php中利用ftp

    $fp=ftp_connect($ftpserver,21,30)

    if(!ftp_login($fp,'username','something'));

    if(!ftp_chdir($fp,$targetDir))

    current directory  ftp_pwd($fp);

    $files=file_nlist($fp,'/');array

    PEAR::NET_FTP

    在PHP5中可以使用SPL功能,

    DirectoryIterator类

  • 相关阅读:
    最大连续序列和
    打印有序链表的公共部分
    字符串最长子串大小
    jvm简介
    大浮点数乘法
    java代码的快速排序理解
    从内存分配分析程序初始化和存储
    时间复杂度
    Filter&Listener
    MVC开发模式&EL表达式&JSTL&三层架构开发
  • 原文地址:https://www.cnblogs.com/phplover/p/3095491.html
Copyright © 2011-2022 走看看