C
C
crazyman2015-11-26 04:51:25
PHP
crazyman, 2015-11-26 04:51:25

How to correctly write to a file?

Hello!
The essence of the question is this:
There are several *.php files that are generated by the client.
For example,

<?php
$selection="Груша, Арбуз, Томат";

At some point, you need to select, for example, Watermelon and place it in the database, extracting it from the file.
I include this file and iterate over the data in it, gradually putting them into a variable, so that I can write it again later.
Then something strange happens on my account ... I write the
file using fwrite, it does not return errors, and then it allows me to write this damn Watermelon to the database, but the file itself behaves extremely strange. It will most likely update, but not now, and if it does not update in a few seconds, then it will not update at all.
The question is, how to properly organize such activities, since I'm obviously doing something wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Taratin, 2015-11-26
@soloromail

There are several *.php files that are generated by the client.

No need to generate any php files for clients. This is usually a potential hole.
Save data for example in some json. In php, working with it is trivial.
https://secure.php.net/manual/ru/function.json-dec...
https://secure.php.net/manual/ru/function.json-enc...
Try https://secure.php.net/manual/en/function.file-put...

A
Artem Spiridonov, 2015-11-26
@customtema

file_get_contents();
file_put_contents();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question