久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

PHP編程文件處理類SplFileObject和SplFileInfo用法實例分析

這篇文章主要介紹了PHP編程文件處理類SplFileObject和SplFileInfo用法,結合實例形式分析了文件處理類SplFileObject和SplFileInfo的功能、定義、使用方法與相關注意事項,需要的朋友可以參考下

本文實例講述了PHP編程文件處理類SplFileObject和SplFileInfo用法。分享給大家供大家參考,具體如下:

php對于大文件的處理除了用以下方法外還可以直接調用linux命令

文件處理類:

SplFileInfo {
/* 方法 */
public __construct ( string $file_name )
public int getATime ( void )   //獲取文件的最后訪問時間
public string getBasename ([ string $suffix ] ) //獲取文件的沒有路徑信息的基本名稱,參數可以為文件后綴,若有參數則返回沒有該后綴的文件基本名稱。
public int getCTime ( void )    //返回文章最后一次變更的時間戳。
public string getExtension ( void )  //獲取文件擴展名
public SplFileInfo getFileInfo ([ string $class_name ] ) //以對象的形式返回文件路徑和名稱
public string getFilename ( void )  //獲取文件名稱,不帶路徑
public int getGroup ( void )  //獲取文件所在組,返回組id
public int getInode ( void )  //獲取文件索引節點
public string getLinkTarget ( void ) //獲取文件鏈接目標
public int getMTime ( void ) //獲取最后修改時間
public int getOwner ( void )   //獲取文件的所有者
public string getPath ( void )  //獲取文件路徑,不帶文件名和最后的斜杠
public SplFileInfo getPathInfo ([ string $class_name ] )  //返回路徑對象
public string getPathname ( void )  //獲取文件路徑
public int getPerms ( void )  //獲取文件權限
public string getRealPath ( void ) //獲取文件絕對路徑,若文件不存在,返回false
public int getSize ( void )  //返回文件大小,單位字節
public string getType ( void ) //返回文件類型,可能是 file, link, dir
public bool isDir ( void ) //判斷是否是目錄,是放回true否則返回false
public bool isExecutable ( void ) //判斷文件是否可執行,返回true,否則返回false
public bool isFile ( void )  //如果文件存在且是一個普通文件(不是鏈接),返回true,否則返回false
public bool isLink ( void ) //判斷文件是否是連接,不是返回false
public bool isReadable ( void )  //判斷文件是否可讀,可讀返回true
public bool isWritable ( void )  //判斷文件是否可寫,可寫返回true
public SplFileObject openFile ([ string $open_mode = "r" [, bool $use_include_path = false [, resource $context = NULL ]]] ) //獲取文件對象信息
public void setFileClass ([ string $class_name = "SplFileObject" ] )
public void setInfoClass ([ string $class_name = "SplFileInfo" ] )
public void __toString ( void )  //以字符串的形式返回文件路徑及名稱
}

使用方法:

$info = new SplFileInfo($file_name);

SplFileObject {
/* 常量 */
const integer DROP_NEW_LINE = 1 ;
const integer READ_AHEAD = 2 ;
const integer SKIP_EMPTY = 4 ;
const integer READ_CSV = 8 ;
/* 方法 */
public string|array current ( void )   //返回文件當前行內容
public bool eof ( void ) //檢測文件是否到末尾,如果到末尾返回true,否則返回false
public bool fflush ( void )  //將緩沖內容輸出到文件,成功時返回 TRUE, 或者在失敗時返回 FALSE。
public string fgetc ( void )  //按字符讀取文件
public array fgetcsv ([ string $delimiter = "," [, string $enclosure = "\"" [, string $escape = "\\" ]]] )  //讀取csv文件
public string fgets ( void )  //按行讀取文件
public string fgetss ([ string $allowable_tags ] ) //按行讀取文件,并去掉html標記
public bool flock ( int $operation [, int &$wouldblock ] )  //文件鎖定或解鎖,返回true或false
/*參數:
LOCK_SH 共享鎖 (讀).
LOCK_EX 獨占鎖 (寫).
LOCK_UN 釋放鎖 (共享或獨占).
LOCK_NB (附加鎖定) 如果不希望flock()在鎖定時堵塞,則應在上述鎖定后加上改鎖(windows上不支持)
flock(LOCK_EX+LOCK_NB);  // 獨占鎖定加上附加鎖定
flock(LOCK_UN+LOCK_NB); */
public int fpassthru ( void )  //輸出文件指針之后的所有數據和字符數
public int fputcsv (array $fields) //將一維數組作為一行輸入csv文件中,返回寫入的字符串長度或false
public string fread ( int $length ) //從文件中讀取指定的字節數,返回讀取的字符串或false
public mixed fscanf ( string $format [, mixed &$... ] ) //從文件中讀取一行并按照指定模式解析
/*例:
$file = new SplFileObject("misc.txt");
while ($userinfo = $file->fscanf("%s %s %s")) {
  list ($name, $profession, $countrycode) = $userinfo;
  // Do something with $name $profession $countrycode
}*/
public int fseek ( int $offset [, int $whence = SEEK_SET ] ) //按字節移動文件指針位置,
/*SEEK_SET 設置文件指針到指定字節位置(默認為該模式).
SEEK_CUR 設置文件指針到當前位置加上指定字節位置.
SEEK_END 設置文件指針到文件末尾加上指定字節位置(此時字節經常為負值).
public array fstat ( void ) //獲取文件信息,以數組形式返回*/
/*
數字下標  關聯鍵名(自 PHP 4.0.6)  說明
0      dev device number - 設備名
1      ino inode number - inode 號碼
2      mode  inode protection mode - inode 保護模式
3      nlink  number of links - 被連接數目
4      uid userid of owner - 所有者的用戶 id
5      gid groupid of owner- 所有者的組 id
6      rdev  device type, if inode device * - 設備類型,如果是 inode 設備的話
7      size  size in bytes - 文件大小的字節數
8      atime  time of last access (unix timestamp) - 上次訪問時間(Unix 時間戳)
9      mtime  time of last modification (unix timestamp) - 上次修改時間(Unix 時間戳)
10     ctime  time of last change (unix timestamp) - 上次改變時間(Unix 時間戳)
11     blksize blocksize of filesystem IO * - 文件系統 IO 的塊大小
12     blocks number of blocks allocated - 所占據塊的數目* Windows 下總是 0。
* - 僅在支持 st_blksize 類型的系統下有效。其它系統(如 Windows)返回 -1。 */
public int ftell ( void ) //返回當前文件位置,文件指針位置
public bool ftruncate ( int $size )  //將文件截斷到指定的長度,若長度大于文件長度用空補齊(文件打開方法對其有影響)
public int fwrite ( string $str [, int $length ] ) //將$str字符串寫入文件,只寫$length長度。放回寫入字節數或null
public array getCsvControl ( void ) //Gets the delimiter and enclosure character used for parsing CSV fields.
public int getFlags ( void ) //Gets the flags set for an instance of SplFileObject as an integer.
public int getMaxLineLen ( void ) //返回一行讀取的最大字節數(在已設置的前提下),若未設置,默認為0
public int key ( void ) //獲取當前行號。
public void next ( void ) //移動到下一行
public void rewind ( void ) //返回到第一行
public void seek ( int $line_pos ) //定位到文件指定行
public void setCsvControl ([ string $delimiter = "," [, string $enclosure = "\"" [, string $escape = "\\" ]]] )
public void setFlags ( int $flags )
public void setMaxLineLen ( int $max_len ) //設置文件讀取一行的最大字節數,若文件每行有10個字符,但設置最大讀取為
public bool valid ( void ) //檢查是否到達文件底部,未到達底部返回 TRUE ,抵達返回false.
}

【網站聲明】本站除付費源碼經過測試外,其他素材未做測試,不保證完整性,網站上部分源碼僅限學習交流,請勿用于商業用途。如損害你的權益請聯系客服QQ:2655101040 給予處理,謝謝支持。

相關文檔推薦

1、模板文件嵌套引用 {include file=***.html} 使用說明: 文章來源:html5模板網 html5code.net 來源:html5模板網 html5code.net 可以嵌套使用,如:index.html 嵌套一個head.html,同時head.html中嵌套com
這篇文章主要介紹了PHP有序表查找之插值查找算法,簡單分析了插值查找算法的概念、原理并結合實例形式分析了php實現針對有序表插值查找的相關操作技巧,需要的朋友可以參考下
下面小編就為大家分享一篇ThinkPHP整合datatables實現服務端分頁的示例代碼,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
下面小編就為大家分享一篇PHP實現APP微信支付的實例講解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
這篇文章主要介紹了PHP實現的多維數組排序算法,結合實例形式對比分析了php針對多維數組及帶有鍵名的多維數組進行排序相關操作技巧與注意事項,需要的朋友可以參考下
這篇文章主要為大家詳細介紹了php結合ajaxuploadfile實現無刷新文件上傳功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下
主站蜘蛛池模板: 最新中文字幕在线 | 操操网站| 国产乱码久久久久久 | 91视视频在线观看入口直接观看 | 91久久久久久久久久久久久 | 亚洲欧美视频在线观看 | 欧美黄 片免费观看 | 精品亚洲一区二区三区 | 国产黄色在线观看 | 国产情侣激情 | 福利视频网站 | 精品一区二区三区在线观看 | 久久99精品国产麻豆婷婷 | 波多野结衣精品在线 | 日韩欧美在线一区 | 日本在线小视频 | 久久久.com | 97av在线| 亚洲在线免费 | 欧美日韩不卡 | jdav视频在线观看免费 | 国产一区二区欧美 | 日韩在线视频免费观看 | 亚洲国产小视频 | 日韩av看片| 人妖一区 | 91玖玖| 国产成人精品一区二区三区在线 | 午夜精品一区二区三区在线视频 | 视频在线亚洲 | 国产1区2区3区 | 久久99精品久久久久久狂牛 | 久久久精品一区 | 久久一区二区三区电影 | 日韩av啪啪网站大全免费观看 | 日本五月婷婷 | 九九热在线免费视频 | 亚洲人成在线播放 | 国产高清视频在线观看 | 国产一区二 | 欧美一级精品片在线看 |