Home > Backend Development > PHP Tutorial > php I wrote this little experiment, but it didn't work?

php I wrote this little experiment, but it didn't work?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-08-29 08:50:57
Original
1122 people have browsed it

Excuse me, where did I write something wrong?

<code>$txt = "R:/1.txt";

date_default_timezone_set("PRC");


fOpen( $txt  ,"a+" );


for($i=0;$i<10 ;$i++)
{
    $str = date("Y-m-d H:i:s",Time());
    sleep(2);
    fwrite( $txt , $str );
}

fClose( $txt );
</code>
Copy after login
Copy after login

Reply content:

Excuse me, where did I write something wrong?

<code>$txt = "R:/1.txt";

date_default_timezone_set("PRC");


fOpen( $txt  ,"a+" );


for($i=0;$i<10 ;$i++)
{
    $str = date("Y-m-d H:i:s",Time());
    sleep(2);
    fwrite( $txt , $str );
}

fClose( $txt );
</code>
Copy after login
Copy after login

Um, the first parameter of fwrite is the file handle. What you are passing here is a path

<code class="php">
$txt = "R:/1.txt";

date_default_timezone_set("PRC");


//打開文件返回一個文件句柄,
$headle = fopen( $txt  ,"a+" );


for($i=0;$i<10 ;$i++)
{
    $str = date("Y-m-d H:i:s",time());
    sleep(2);
    fwrite($headle , $str );
}

fClose( $txt );
</code>
Copy after login
Related labels:
php
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template