Skip to main content

Write a PHP script to count lines in a file.

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>Count File</title>
</head>
<body>
 <p>Count File</p>
 <p>Count File</p>
 <p>Count File</p>
 <p>Count File</p>
</body>
</html>
<?php 
$file =basename($_SERVER['PHP_SELF']);
$no_of_lines =count(file($file));
echo $no_of_lines;
?>
Output:

Comments