亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

PHP ?? ??

PHP ?? ??


??? ???

??? ???? ????? ? ?? ?? ??? ?? ?? ?????????.

?? ???? ??????? ??????? ???? ???? ?? ??? ??? ?? ?? ????? ?? ???? ??? ?????.

? ?? ?? ??

?? ??? ???? ???

???? ??? ????

?? ??

??? ????? ???? ???? ?? ????? ? ?? ?? ??? ????. ??? ??? ????? ?? ??? ??? ???.

? ??? ?? FOPEN ??? ?????.

? ??? ?? FWRITE ??? ?????.

? ??? ????. , FCLose ?? ??

Open File

fopen() ??? PHP?? ??? ?? ? ?????.

? ??? ? ?? ?????? ??? ??? ??? ???? ? ?? ????? ??? ?? ? ??? ??? ?????.

<html>
 <body>
 <?php
 $file=fopen("welcome.txt","r");
 ?>
 </body>
 </html>

??? ???? ? ? ????. ?? ??:

QQ圖片20161009145912.png

??: fopen() ??? ??? ??? ? ? ??? 0(false)? ?????.

?

fopen() ??? ??? ??? ? ? ?? ?? ?? ?? ???? ?????:

<html>
 <body>
 <?php
 $file=fopen("welcome.txt","r") or exit("Unable to open file!");
 ?>
 </body>
 </html>

?? ??

fwrite() ??? ??? ?? ? ?????

fwrite?? ? ?? ?? ????? ????. handler? fopen? ????? ?? ? ???? Resource ???? string? ? ??????

int fwrite (resource $handle , string $string [, int $length ] )

??? ???? fwrite? ? ?? ?? ?????. ??? ???? false? ?????. ??>

?

<?php
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = "Bill Gates\n";
fwrite($myfile, $txt);
$txt = "Steve Jobs\n";
fwrite($myfile, $txt);
fclose($myfile);
?>

"newfile.txt" ??? ? ? ????. ??? ? ??? ??? ??? $txt?? ???? "Bill Gates"? ???? ? ???? "Steve Jobs"? ?????. ??? ??? ? fclose() ??? ???? ??? ????.

"newfile.txt" ??? ?? ??? ????:

Bill Gates

Steve Jobs

?? file

fread? while ?? ???? ?? ?? ??? ?? ? ?????. ? ?? ????? ?? ?? ??? ?? ???? ??? ?????.

string fread(resource $handle, int $length)

??

echo fread($resource, 1024);

?? 1024?? ?? ? ????. ?? ??? ???

?? ??

fclose() ??? ?? ??? ?? ? ?????.

<?php
 $file = fopen("test.txt","r");
 
 //執(zhí)行一些代碼
 
 fclose($file);
 ?>

? ?? ??? ?(EOF)

feof() ??? ??? ?(EOF)? ????? ??? ?????.

feof() ??? ??? ? ? ?? ???? ??? ? ?????.

??: w, a ? x ????? ?? ?? ??? ?? ? ????!

if (feof($file)) echo "?? ?";

??? ? ?? ??

fgets() ??? ??? ????. ???? ? ?? ??? ????.

??: ? ??? ???? ?? ???? ?? ?? ?????.

?

?? ???? ??? ?? ??? ??? ? ?? ????.

<?php
 $file = fopen("welcome.txt", "r") or exit("無(wú)法打開文件!");
 // 讀取文件每一行,直到文件結(jié)尾
 while(!feof($file))
 {
     echo fgets($file). "<br>";
 }
 fclose($file);
 ?>

??? ???? ????

fgetc() ??? ???? ???? ??? ?? ? ?????.

??: ? ??? ???? ?? ???? ?? ??? ?????.

?

?? ?? ??? ?? ??? ??? ? ??? ????.

<?php
 $file=fopen("welcome.txt","r") or exit("無(wú)法打開文件!");
 while (!feof($file))
 {
     echo fgetc($file);
 }
 fclose($file);
 ?>

file_put_contents

?? ??? ???, fopen ? fclose? ?? ???? ?????. PHP5?? ??? ??

int file_put_contents ( string $filename , mix $data [, int $flags = 0 [, resources $ context ]] )

file_put_contents? fopen + fwrite + fclose? ???? ?? ????

file_put_contents('file', "hello worldn");

file_put_contents('file', "hello worldn ", FILE_APPEND);

file_get_contents

string file_get_contents( string $filename [, bool $use_include_path = false [, resources$context [, int $offset = -1 [, int $maxlen ]]]] )

file_get_contents? fopen + fread + fclose

echo file_get_contents('file');

??? ???? ?? ????. ?? ?? ??

S file_exists? ?? ??? ?? ??? ???? ??? ????? ??? ??? ?? true ?? false

S filesize? ?? ??? ????, ??? ??

S unlink? ??? ?? ??? ???? ??? ??? ? ????


PHP ?? ??? ?? ???

For PHP ?? ??? ??? ?? ?? ?? ???? ??? PHP ?? ??? ?? ???? ?????.


???? ??
||
<html> <body> <?php $file=fopen("welcome.txt","r"); ?> </body> </html>