How can PHP scripts be used to search for and replace specific strings within a file?
To search for and replace specific strings within a file using PHP, you can read the content of the file, use the `str_replace()` function to replace the desired string, and then write the modified content back to the file. This can be done by opening the file in read/write mode, reading its content, performing the replacement, and then writing the modified content back to the file.
<?php
$file = 'example.txt';
$search = 'old_string';
$replace = 'new_string';
$content = file_get_contents($file);
$content = str_replace($search, $replace, $content);
file_put_contents($file, $content);
?>