83 php files

WBOY
WBOYOriginal
2016-07-29 09:07:041088browse

83 php文件
83 php文件
83 php文件


1. Open the file
83 php文件
83 php文件
83 php文件
83 php文件

<code><span><span><?php</span><span>//1.文件信息</span><span>//打开文件</span><span>$file_path</span> = <span>'./file/test.txt'</span>;
<span>$fp</span> = fopen(<span>$file_path</span>,<span>'r'</span>);

<span>if</span>(<span>$fp</span>){
    <span>$file_info</span> = fstat(<span>$fp</span>);
    var_dump(<span>$file_info</span>);
    <span>echo</span> date(<span>"Y-m-d H:i:s"</span>,<span>$file_info</span>[<span>'mtime'</span>]) . <span>'<br/>'</span>;
    <span>echo</span> date(<span>"Y-m-d H:i:s"</span>,<span>$file_info</span>[<span>'atime'</span>]) . <span>'<br/>'</span>;
    <span>echo</span> date(<span>"Y-m-d H:i:s"</span>,<span>$file_info</span>[<span>'ctime'</span>]) . <span>'<br/>'</span>;
}<span>else</span>{
    <span>echo</span><span>'打开文件失败'</span>;
}

fclose(<span>$fp</span>);

<span>echo</span> filemtime(<span>$file_path</span>) . <span>'<br/>'</span>;
<span>echo</span> fileatime(<span>$file_path</span>) . <span>'<br/>'</span>;
<span>echo</span> filectime(<span>$file_path</span>) . <span>'<br/>'</span>;</span></code>

2. Read the file
83 php文件
83 php文件

<code><?php

//<span>1</span>.文件信息

//打开文件
<span>$file_path</span> = <span>'./file/test.txt'</span>;

//****第一种读取方式******
/*<span>if</span>(file_exists(<span>$file_path</span>)){
    <span>$fp</span> = fopen(<span>$file_path</span>,<span>'a+'</span>);
    //读内容,并输出

    <span>$con</span> = fread(<span>$fp</span>,filesize(<span>$file_path</span>));
    //在默认情况下,我们得到的内容输出到网页后,不会换行
    //因为网页不会识别 \r\n 是换行符,要把 \r\n 替换成 <br/>
    <span>$con</span> = str_replace(<span>"\r\n"</span>,<span>"<br/>"</span>,<span>$con</span>);
    <span>echo</span><span>$con</span>;
}<span>else</span>{
    <span>echo</span><span>'文件不存在'</span>;
}

fclose(<span>$fp</span>);*/

//**********第二种读取方式**********
/*<span>$con</span> = file_get_contents(<span>$file_path</span>);
<span>$con</span> = str_replace(<span>"\r\n"</span>,<span>"<br/>"</span>,<span>$con</span>);
<span>echo</span><span>$con</span>;*/

//**********第三种读取方式,循环读取,对付大文件**********

<span>$fp</span> = fopen(<span>$file_path</span>,<span>'r'</span>);
//我们设置一次读取<span>1024</span>个字节
<span>$buffer</span> = <span>1024</span>;
//一边读,一边判断是否到达文件末尾
<span>while</span>(!feof(<span>$fp</span>))
{
    <span>$str</span> = fread(<span>$fp</span>,<span>$buffer</span>);
    <span>echo</span><span>$str</span>;
}

fclose(<span>$fp</span>);</code>

83 php文件
83 php文件
83 php文件

').addClass(' pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the 83 php files, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn