Not the most efficient way of doing things, but should suffice if you are doing some debugging/profiling and not worried about performance:
// in PHP5 this also includes the original file
$files = get_included_files();
if (version_compare(phpversion(), '5.0.0') == -1) {
// PHP4 does not include the original file (so add it!!)
$files[] = $_SERVER['SCRIPT_FILENAME'];
}
$lines_of_code = 0;
foreach ($files as $file) {
// should be safe to assume that the files exist and
// are readable since they have been included!!
$lines_of_code += count(file($file));
}
echo 'Total lines of code = '.$lines_of_code."<br />\n";