使用PHP从文件中删除多行

Let's say I have a file called 'file.php' in which is the following code:

<?php
$var = 'something';
echo '<p>' . $var . '</p>';
?>

Is it possible to delete these lines with PHP, without altering the rest of the file?

Once these lines have been output (sent to the browser) you will not be able to "delete" them solely using PHP.

You'll need to use a client-side scripting language such as JavaScript to get a handle on the <p> tag for example and then either hide it or remove it from the DOM.