新人提问:不明白ftell()解决思路
新人提问:不明白ftell()
$fp = fopen('exa', 'r');
$data = fgets($fp, 15);
echo ftell($fp);
fclose($fp);
?>
这个例子中输出:13
若15改成1046之类的比较大的数,也输出13;
若15改成13,则输出12
究竟是怎么回事呢?
------解决方案--------------------
首先,你的'exa'文件这一行的指针宽度是13,而指针起始是从0开始,因此当你选择15或者更大的时候,只要超过本身宽度,那么只能输出最大的宽度,也就是13.
其次,由于指针是从0开始算的,所以$data = fgets($fp, num);,而指针实际是从0开始,那么ftell($fp)的值肯定是num-1,比如你fgets($fp, 5),那么ftell($fp)就会是4。
所以你“若15改成13,则输出12”,是因为13没有超过最大宽度,因此输出的是13-1。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











PHP is a popular programming language used for developing web applications and dynamic websites. When processing file input, the fgets() function is typically used to read a line of text from a file. However, sometimes the fgets() function ignores newline characters at the end of a line, which can lead to program errors and unpredictable results. In this article, we will explore the causes and solutions to this problem.

Introduction to PHP functions—fgets(): Read a line from a file In PHP, many functions are provided for reading and writing files. Among them, the fgets() function is one of the functions used to read the content line by line from the file. This article will introduce the fgets() function and demonstrate its usage through code examples. The fgets() function is one of the file input functions in PHP, used to read a line of content from a file. Its basic syntax is as follows: stringfgets(resource$ha

To install and use exa on a Linux system, you can follow these steps: Open Terminal: In Linux systems, press the Ctrl+Alt+T key combination to open the terminal. Download exa: exa is a modern ls replacement tool that provides a more beautiful and feature-rich file listing. Enter the following command in the terminal to download exa: wget This command will download the compressed file of exa from GitHub. Decompress exa: Use the following command to decompress the downloaded exa compressed file: unzipexa-linux-x86_64-0.10.1.zip After decompression, an executable file named exa will be generated. Install exa: Copy the exa file to the system's

The data folder contains system and program data, such as software settings and installation packages. Each folder in the Data folder represents a different type of data storage folder, regardless of whether the Data file refers to the file name Data or the extension. Named data, they are all data files customized by the system or program. Data is a backup file for data storage. Generally, it can be opened with meidaplayer, notepad or word.

The solution to the garbled mysql load data: 1. Find the SQL statement with garbled characters; 2. Modify the statement to "LOAD DATA LOCAL INFILE "employee.txt" INTO TABLE EMPLOYEE character set utf8;".

The differences are: 1. xdata usually refers to independent variables, while data refers to the entire data set; 2. xdata is mainly used to establish data analysis models, while data is used for data analysis and statistics; 3. xdata is usually used for regression Analysis, variance analysis, predictive modeling, data can be analyzed using various statistical methods; 4. xdata usually requires data preprocessing, and data can contain complete original data.

Shortly after the launch of the Humane Ai Pin, scathing reviews revealed that the AI gadget was anything but ready for the market, as most of the originally advertised features either didn't work properly or were simply missing, the battery life was

No, data in the vue component must be a function. Components in Vue are used for reuse. In order to prevent data reuse, they are defined as functions. The data data in the vue component should be isolated from each other and not affect each other. Every time the component is reused, the data data should be copied once. Later, when the data data in the component is changed in a reused place, other data will be copied. If the data data of reused local components is not affected, you need to return an object as the status of the component through the data function.
