常用工具: 简繁转换 HTML/JS互转 Url编码Escape解析 Unicode编码转换 设为首页 加入收藏夹
更多内容
" id="arctext" class="center" " class="arcinfo center" " id="slistl" class="left" " id="mid_slistl_sch" class="left" " id="mid_slistl_adv" class="left" " id="mid_slistl_adv2" " src="http://www.fzs8.net/d/js/acmsd/middle2.js"
文章正文

ASP Hex 函数

来源:  网络收集  字体:[ ]
站内搜索系统
文章正文

php fgets() 函数

来源:  网络收集  2006-09-30 00:00:00 字体:[ ]

Definition and Usage
定义和用法

The fgets() function returns a line from an open file.
fgets()函数的作用是:从文件指针中读取一行。

The fgets() function stops returning on a new line, at the specified length, or at EOF, whichever comes first.
fgetcsv()函数可以对是否输出新的一行词段作出设置,具体见下面的语法;当到达文档段落末尾[EOF]时,该函数将停止运行。

This function returns FALSE on failure.
如果运行失败,函数将返回False。

Syntax
语法

fgets(file,length)

Parameter
参数
Description
描述
file Required. Specifies the file to read from
必要参数。指定需要读取的文件对象
length Optional. Specifies the number of bytes to read. Default is 1024 bytes.
可选参数。指定需要读取的字节数。默认值是1024个字节


Example 1
案例1

<?php
$file = fopen("test.txt","r");echo fgets($file);fclose($file);
?> 

The output of the code above will be:
上述代码将输出下面的结果:

Hello, this is a test file.


Example 2
案例2

Read file line by line:
逐行读取文件:

<?php
$file = fopen("test.txt","r");
while(! feof($file))  {  echo fgets($file). "<br />";  }
fclose($file);?>

The output of the code above will be:
上述代码将输出下面的结果:

Hello, this is a test file. There are three lines here. This is the last line.


  
上一篇:php fgetcsv() 函数
下一篇:php fgetss() 函数
最新文章
推荐文章
热门文章
版权所有:IT加油站   COPYRIGHT © 2007 WWW.FZS8.NET ALL RIGHTS RESERVED.
闽ICP备08008535号