Friday, October 24, 2025
HomeLanguagesPHP | SplFileObject getMaxLineLen() Function

PHP | SplFileObject getMaxLineLen() Function

The SplFileObject::getMaxLineLen() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to get maximum line length.

Syntax:

int SplFileObject::getMaxLineLen( void )

Parameters: This function does not accept any parameter.

Return values: This function returns the maximum length of line. The default value is set to 0.

Below Programs illustrate the SplFileObject::getMaxLineLen() function in PHP:

Program 1:




<?php
  
// Create an SplFile Object
$file = new SplFileObject("gfg.txt");
  
// Print Length
var_dump($file->getMaxLineLen());
  
// Create an SplFile Object
$file = new SplFileObject(__FILE__);
  
// Print Length
var_dump($file->getMaxLineLen());
  
?>


Output:

int(0)
int(0)

Program 2:




<?php
  
// Create an SplFile Object
$gfg = new SplFileObject("gfg.txt");
  
// Print Length
var_dump($gfg->getMaxLineLen());
  
// Set length 
$gfg->setMaxLineLen(20);
var_dump($gfg->getMaxLineLen());
  
?>


Output:

int(0) int(20)

Reference: http://php.net/manual/en/splfileobject.getmaxlinelen.php

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS