X
X
Xakephp2014-10-05 16:24:01
PHP
Xakephp, 2014-10-05 16:24:01

How to replace the file_put_contents function?

You need to replace the file_put_contents function with something else.
Now the function creates files and saves texts there,
I would like to replace a bunch of files with one so that the file becomes like a database and stores information in itself like a folder with files

$tank = "bd/".$text.".txt";
if (file_exists($tank)) {
  } else {
    file_put_contents($tank, $text = "<span class='$random'>$text</span><br>");
  }

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Taratin, 2014-10-05
@Xakephp

php.net/manual/ru/function.fopen.php
php.net/manual/ru/function.fwrite.php
php.net/manual/ru/function.fclose.php

K
KorsaR-ZN, 2014-10-05
@KorsaR-ZN

This is the third time I've seen this code here, and I just can't ask the question, have you ever heard of negation in logical conditions?
So your code can be shortened and readability improved...

$tank = "bd/".$text.".txt";
if (!file_exists($tank)) {
    file_put_contents($tank, $text = "<span class='$random'>$text</span><br>");
}

A
Andrey Baranichenko, 2014-10-05
@burick

Try to look in this direction . Working with INI files in PHP , maybe this is what you need

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question