the text is written to the file like this, this example does not work

//Файлы $admfile = 'admin.php'; $admexphrase = "PHP_EOL" . '<p><a href="admintoursample.php">toursample.php</a></p>'; if(file_put_contents($admfile, PHP_EOL . $admexphrase, FILE_APPEND)) { echo "succesadm"; } //Удаляется вот так $admcont = file_get_contents($admfile); $admcontold = array("$admexphrase"); $admcontnew = array(""); $admphrase = str_replace($admcontold, $admcontnew, $admcont); if(file_put_contents($admfile, $admphrase)) { echo "succes page\n"; } 

    1 answer 1

    solved the question who will need this code

    new.php // creates a text file

     $file = "text.php"; $text = "testvalue"; $sometext = PHP_EOL . $text; if((file_put_contents($file, $sometext)) == TRUE) { echo "ok2"; echo $sometext; } 

    del.php // deletes the file and PHP_EOL

     $file = "text.php"; $filecont = file_get_contents($file); //работает $oldtext ="testvalue"; $old = PHP_EOL . $oldtext; $new = ""; $contold = array($old); $contnew = array($new); $newphrase = str_replace($contold, $contnew, $filecont); if(file_put_contents($file, $newphrase)) echo 'ok';