This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
uphp:functions:ftell [2017/03/31 13:43] jeff created |
uphp:functions:ftell [2021/09/13 05:57] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
======ftell====== | ======ftell====== | ||
- | < | + | < |
- | Position | + | Return |
====Description==== | ====Description==== | ||
- | <well size=" | + | <well size=" |
- | <html>( | + | <span style=" |
+ | <span style=" | ||
<span style=" | <span style=" | ||
- | <span style=" | + | <span style=" |
- | <span style=" | + | |
- | <span style=" | + | |
- | <span style=" | + | |
- | <span style=" | + | |
<span style=" | <span style=" | ||
</ | </ | ||
- | This function will relocate | + | Return |
- | ====Parameters==== | + | ====Parameter==== |
- | < | + | < |
- | + | ||
- | <html>< | + | |
- | + | ||
- | < | + | |
- | + | ||
- | * **0** - Seek from the **start | + | |
- | * **1** - Seek from the **current position** | + | |
- | * **2** - Seek from the **end of the file** (in reverse) | + | |
====Return Values==== | ====Return Values==== | ||
- | None | + | < |
====Example==== | ====Example==== | ||
<code php> | <code php> | ||
- | <? | + | <pre><? |
- | $fp=fopen("/index.cgi"," | + | $file="/ftell_example.txt" |
+ | $fp=fopen($file,"w"); | ||
if ($fp) { | if ($fp) { | ||
- | | + | |
- | | + | fwrite($fp," |
- | print($data); | + | print(" |
+ | | ||
+ | print(" | ||
+ | print(" | ||
fclose($fp); | fclose($fp); | ||
+ | unlink($file); | ||
} else { | } else { | ||
- | print(" | + | print(" |
} | } | ||
- | ?> | + | ?></ |
+ | |||
+ | The above example will ouput: | ||
+ | |||
+ | < | ||
+ | Beginning position: 0 | ||
+ | Position after writing 10 characters: 10 | ||
+ | Position after moving pointer -2: 8 | ||
+ | The character at that position is: 8 | ||
</ | </ | ||
Line 56: | Line 58: | ||
[[fopen()]] - Open a file for reading or writing | [[fopen()]] - Open a file for reading or writing | ||
- | [[fread()]] - Return bytes from a file or stream | + | [[fseropen()]] - Open the serial port at the specified baud rate with optional parameters |
- | [[fgets()]] - Return a single line from a file or stream, with optional size limit | + | [[f485open()]] - Open the RS-485 port at the specified baud rate and parity |
- | [[fwrite()]] - Write data to a file or stream | + | [[fsockopen()]] - Open an internet socket connection with optional timeout |
+ | |||
+ | [[fread()]] - Read bytes from a file, stream or socket | ||
+ | |||
+ | [[fgets()]] - Return a single line from a file, stream or socket, with optional size limit | ||
+ | |||
+ | [[fwrite()]] - Write data to a file, stream | ||
+ | |||
+ | [[feof()]] - Test if no more data is available in a file, stream | ||
+ | |||
+ | [[filesize()]] - Return the size of a file, or the number of unread bytes in a stream or socket | ||
+ | |||
+ | [[fseek()]] - Position the file pointer in an open file | ||
[[fclose()]] - Close a file, stream or socket | [[fclose()]] - Close a file, stream or socket | ||
+ | |||
+ | [[unlink()]] - Remove a file (delete it) | ||