PHP ftell() Function
In this chapter you will learn:
- Definition for PHP ftell() Function
- Syntax for PHP ftell() Function
- Parameter for PHP ftell() Function
- Return for PHP ftell() Function
- Example - Returns the current position in an open file
Definition
The ftell() function returns the current position in an open file.
Syntax
PHP ftell() Function has the following syntax.
ftell(file)
Parameter
Parameter | Is Required | Description |
---|---|---|
file | Required. | Open file to check |
Return
Returns the current file pointer position, or FALSE on failure.
Example
Returns the current position in an open file
<?php/*from j a v a 2s . c o m*/
$file = fopen("test.txt","r");
// print current position
echo ftell($file);
// change current position
fseek($file,"25");
// print current position again
echo "\n";
echo ftell($file);
fclose($file);
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP ftruncate() Function
- Syntax for PHP ftruncate() Function
- Parameter for PHP ftruncate() Function
- Return for PHP ftruncate() Function
- Example - truncates an open file to the specified length
Home » PHP Tutorial » PHP File Functions