File::count()

Counts number of lines in the file content.

Table of Contents
  1. Description
  2. Example

Description

File::count(): int;

This method is a requirement to be able to implement the Countable interface and aims to make the object countable via the count() function. This method is public, so it can also be called as how you would call any public methods in general. This method returns the number of lines in the file content if the file exists, otherwise, it returns 0.

Example

$file = new File('.\path\to\file.txt');

test($file->count()); // Returns the number of lines in the file content
test(count($file)); // Returns the number of lines in the file content

File::count()

Counts number of lines in the file content.

File::size()

Gets the file sizes in human readable string format.