php fscanf()函数使用方法详解
时间:2011-06-10
来源:互联网
php fscanf()函数使用方法详解
The fscanf() function parses the input from an open file according to the specified format.
fscanf()函数的作用是:从文件中按照指定的格式输入。
Syntax
语法
fscanf(file,format,mixed)
Parameter参数Description描述
fileRequired. Specifies the file to check
必要参数。指定文件对象
formatRequired. Specifies the format.
必要参数。指定格式
Possible format values:
可用的格式值:
%% - Returns a percent sign
%% - 返回一个“%”
%b - Binary number
%b – 二进制数
%c - The character according to the ASCII value
%c – 某字符所对应的ASCII值
%d - Signed decimal number
%d – 包含正负号的十进制数(可包含正负数)
%e - Scientific notation (e.g. 1.2e+2)
%e – 科学技术符号(例如:1.2e+2)
%u - Unsigned decimal number
%u – 不包含正负号的十进制数
%f - Floating-point number (local settings aware)
%f – 浮点数字(本地属性)
%F - Floating-point number (not local settings aware)
%F – 浮点数字(非本地属性)
%o - Octal number
%o – 十进制数字
%s - String
%s – 字符串
%x - Hexadecimal number (lowercase letters)
%x – 十六进制数(小写字母)
%X - Hexadecimal number (uppercase letters)
%X – 十六进制数(大写字母)
Additional format values. These are placed between the % and the letter (example %.2f):
其它的文本格式值。它是位于%和字母之间的(如:%.2f):
+ (Forces both + and - in front of numbers. By default, only negative numbers are marked)
+(在数字前面加上‘+’或‘-’来定义数字的正负性;默认情况下,正数不做标记)
' (Specifies what to use as padding. Default is space. Must be used together with the width specifier. Example: %'x20s (this uses "x" as padding)
’(指定使用旁白[padding]的类型。默认是空格space,它必须同时指定宽度,例如:%'x20s (这里使用 "x" 作为旁白[padding]) )
- (Left-justifies the variable value)
-(向左调整变量值)
[0-9] (Specifies the minimum width held of to the variable value)
[0-9](指定了变量值的最小宽度)
.[0-9] (Specifies the number of decimal digits or maximum string length)
.[0-9](指定了十位数字或最大字符串长度)
Note: If multiple additional format values are used, they must be in the same order as above.
注意:如果要使用多个上述的值,顺序必须按照上面的顺序,不能打乱。
mixedOptional.
可选参数
Tips and Notes
注意点
Note: Any whitespace in the format string matches any whitespace in the input stream. This means that a tab (/t) in the format string can match a single space character in the input stream.
注意:任何format的值中的空白部分[whitespace]与input内容相似;这意味着tab键(/t)[制表符]和input内容的一个单一的空格[space]相似。
The fscanf() function parses the input from an open file according to the specified format.
fscanf()函数的作用是:从文件中按照指定的格式输入。
Syntax
语法
fscanf(file,format,mixed)
Parameter参数Description描述
fileRequired. Specifies the file to check
必要参数。指定文件对象
formatRequired. Specifies the format.
必要参数。指定格式
Possible format values:
可用的格式值:
%% - Returns a percent sign
%% - 返回一个“%”
%b - Binary number
%b – 二进制数
%c - The character according to the ASCII value
%c – 某字符所对应的ASCII值
%d - Signed decimal number
%d – 包含正负号的十进制数(可包含正负数)
%e - Scientific notation (e.g. 1.2e+2)
%e – 科学技术符号(例如:1.2e+2)
%u - Unsigned decimal number
%u – 不包含正负号的十进制数
%f - Floating-point number (local settings aware)
%f – 浮点数字(本地属性)
%F - Floating-point number (not local settings aware)
%F – 浮点数字(非本地属性)
%o - Octal number
%o – 十进制数字
%s - String
%s – 字符串
%x - Hexadecimal number (lowercase letters)
%x – 十六进制数(小写字母)
%X - Hexadecimal number (uppercase letters)
%X – 十六进制数(大写字母)
Additional format values. These are placed between the % and the letter (example %.2f):
其它的文本格式值。它是位于%和字母之间的(如:%.2f):
+ (Forces both + and - in front of numbers. By default, only negative numbers are marked)
+(在数字前面加上‘+’或‘-’来定义数字的正负性;默认情况下,正数不做标记)
' (Specifies what to use as padding. Default is space. Must be used together with the width specifier. Example: %'x20s (this uses "x" as padding)
’(指定使用旁白[padding]的类型。默认是空格space,它必须同时指定宽度,例如:%'x20s (这里使用 "x" 作为旁白[padding]) )
- (Left-justifies the variable value)
-(向左调整变量值)
[0-9] (Specifies the minimum width held of to the variable value)
[0-9](指定了变量值的最小宽度)
.[0-9] (Specifies the number of decimal digits or maximum string length)
.[0-9](指定了十位数字或最大字符串长度)
Note: If multiple additional format values are used, they must be in the same order as above.
注意:如果要使用多个上述的值,顺序必须按照上面的顺序,不能打乱。
mixedOptional.
可选参数
Tips and Notes
注意点
Note: Any whitespace in the format string matches any whitespace in the input stream. This means that a tab (/t) in the format string can match a single space character in the input stream.
注意:任何format的值中的空白部分[whitespace]与input内容相似;这意味着tab键(/t)[制表符]和input内容的一个单一的空格[space]相似。
作者: feiyang10086 发布时间: 2011-06-10
火速围观!牛人招PHP技术员-出得厅堂,下得厨房,进得洞房!有木有!!有木有!!
http://bbs.phpchina.com/thread-214382-1-1.html 这公司太有才了,做PHP的还要求会武功,找金庸大师学学吧,笑死俺了哈
http://bbs.phpchina.com/thread-214382-1-1.html 这公司太有才了,做PHP的还要求会武功,找金庸大师学学吧,笑死俺了哈
作者: fanglq04: 发布时间: 2011-06-10
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28