I wanted to remove a certain piece of code in a php file, I decided to do it with str_replace (). In this way:
$filename = 'check.php'; $a = 'public function actionTitle1() { $this->title = "Title 1"; $this->meta_author = "Arandar"; $this->meta_copyright = "Copyright © 2018 Arandar. All Rights Reserved."; $content = $this->view->render("title1", array(), true); $this->render($content); }'; $b = ''; $file1 = file_get_contents($filename); $file1 = str_replace($a, $b, $file1); file_put_contents($filename, $file1); This is how the file looks like, where you need to delete the file in compliance with tabs and hyphenations:
public function actionTitle1() { $this->title = "Title 1"; $this->meta_author = "Arandar"; $this->meta_copyright = "Copyright © 2018 Arandar. All Rights Reserved."; $content = $this->view->render("title1", array(), true); $this->render($content); } But alas, does not work. The file is updated, but remains unchanged. Tell me, please, what is the mistake, because I’ve already been in everything, I found some options on JS, but I would like to use PHP.