Easy Tutorial
❮ Func Math Exp Func Simplexml Import Dom ❯

PHP fscanf() Function



Definition and Usage

The fscanf() function parses input from an open file according to the specified format.

Syntax

Parameter Description
file Required. Specifies the file to check.
format Required. Specifies the format. Possible format values: %% - Returns a percent sign %<br> %b - Binary number<br> %c - Character corresponding to the ASCII value<br> %d - Signed decimal number<br> %e - Scientific notation (e.g., 1.2e+2)<br> %u - Unsigned decimal number<br> %f - Floating point number (locale aware)<br> %F - Floating point number (non-locale aware)<br> %o - Octal number<br> %s - String<br> %x - Hexadecimal number (lowercase letters)<br> %X - Hexadecimal number (uppercase letters) Additional format values. Must be placed between % and the letter (e.g., %.2f): + (Adds a + or - sign before the number. By default, only negative numbers are marked, positive numbers are not marked)<br> ' (Specifies what to use as padding, default is a space. It must be used with a width specifier. For example: %'x20s (uses "x" as padding))<br> - (Left-justifies the variable value)<br> [0-9] (Specifies the minimum width of the variable value)<br> .[0-9] (Specifies the number of decimal places or the maximum string length) Note: If multiple format values are used, they must be used in the order shown above, without rearranging.
mixed Optional.

Tips and Notes

Note: Any whitespace in the format string matches any whitespace in the input stream. This means that a tab character \t in the format string also matches a single space character in the input stream.


❮ Func Math Exp Func Simplexml Import Dom ❯