Хотел удалить определенный кусок кода в php-файле, решил сделать это с str_replace(). Таким образом:
$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);
Вот так выглядит файл, где нужно удалить файл с соблюдением табуляции и переносов:
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);
}
Но увы, не работает. Файл обновляется, однако остается без изменений. Подскажите, будьте добры, в чем ошибка, ибо уже все облазил, нашел какие-то варианты на JS, однако хотелось бы на PHP.