I’ve been doing some work with different PHP scripts and had a quick question. In quite a few of them there are commented out lines like these:
/*
$a = 1; $b = 2; $x = 1;
$y = $a * $x + $b;
if ( $y < 5 )
*/
Are these lines safe to delete if they are commented out? What’s the point of having code in files that’s just commented out?
Nothing. Some developers do it for backlogging old code. This is bad practice, as one should use source control (such as SVN or GIT) instead, and all the history will be in there along with commit messages why it was commented out/replaced.
They’re definitely safe to delete, but you might want to ask the developer why they commented them out instead of simply removing them.