New questions: Do not understand ftell () solution ideas
Source: Internet
Author: User
New question: Do not understand Ftell ()
$fp = fopen (' Exa ', ' R ');
$data = fgets ($fp, 15);
Echo Ftell ($FP);
Fclose ($FP);
?>
Output in this example: 13
If 15 is changed to 1046 of the larger number, also output 13;
If 15 is changed to 13, the output 12
What the hell is going on here?
------Solution--------------------
First of all, your ' exa ' file has a pointer width of 13, and the pointer starts at 0, so when you choose 15 or greater, you can only output the maximum width, or 13, if you exceed the width.
Second, since the pointer is calculated from 0, so $data = fgets ($fp, num), and the pointer is actually starting from 0, then the value of Ftell ($FP) is definitely num-1, such as you Fgets ($FP, 5), then Ftell ($FP) is 4.
So you "If 15 is changed to 13, then output 12" is because 13 does not exceed the maximum width, so the output is 13-1.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.