Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #17358
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | "J.O. Aho" <user@example.net> |
| Newsgroups | comp.lang.php |
| Subject | Re: Storing a number inside a file |
| Date | Tue, 18 Apr 2017 06:54:35 +0200 |
| Lines | 23 |
| Message-ID | <ellkgbFeqngU1@mid.individual.net> (permalink) |
| References | <acaf6429-3976-44a5-9331-2339742028a1@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net 3UgJIS1fd2rbian3C9dp1wfSqeilhNpQsxTVyLc4vTj4X1Brkw |
| Cancel-Lock | sha1:hbyUtNZm5ugh/pB9kcM7+rrcoro= |
| X-Enigmail-Draft-Status | N1110 |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 |
| In-Reply-To | <acaf6429-3976-44a5-9331-2339742028a1@googlegroups.com> |
| Xref | csiph.com comp.lang.php:17358 |
Show key headers only | View raw
On 04/18/17 05:58, bit-naughty@hotmail.com wrote: > I want to store a number, like "23" inside a file. The number will be the only thing in the file, > and it will be incremented whenever I want it to. However - the length of the number can be anything, > eg. 429 or 1985409...or whatever - ie. it's *length* can be anything. How do I do this? Here is a simple example: https://www.w3schools.com/PHP/php_file_create.asp Error handling not the perfect one, but you will be able to improve. > And of course, how do I read the number inside the file when I want? To read the data in the file to a string you can use file_get_contents, see http://www.php.net/manual/en/function.file-get-contents.php And then convert it to an integer, use intval, see http://php.net/manual/en/function.intval.php -- //Aho
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Storing a number inside a file bit-naughty@hotmail.com - 2017-04-17 20:58 -0700
Re: Storing a number inside a file "J.O. Aho" <user@example.net> - 2017-04-18 06:54 +0200
Re: Storing a number inside a file Mi Na <ya12983@mail.com> - 2021-07-23 00:52 -0700
csiph-web