PHP | SplFileObject setMaxLineLen() Function
Last Updated :
20 Dec, 2018
The SplFileObject::setMaxLineLen() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to set the maximum length of line length.
Syntax:
void SplFileObject::setMaxLineLen( $len )
Parameters: This function accepts single parameter $len which is used to specify the maximum length of line.
Return values: This function returns the maximum length of line. The default value is 0.
Below Programs illustrate the SplFileObject::setMaxLineLen() function in PHP:
Program 1:
<?php
$gfg = new SplFileObject( "gfg.txt" );
var_dump( $gfg ->getMaxLineLen());
$gfg ->setMaxLineLen(20);
var_dump( $gfg ->getMaxLineLen());
?>
|
Output:
int(0) int(20)
Program 2:
<?php
$GFG = array (
"dummy.txt" ,
"gfg.txt" ,
"frame.txt"
);
foreach ( $GFG as & $arr )
{
$gfg = new SplFileObject( $arr );
var_dump( $gfg ->getMaxLineLen());
$gfg ->setMaxLineLen(50);
echo "After = " ;
var_dump( $gfg ->getMaxLineLen());
echo "</br>" ;
}
?>
|
Output:
int(0) After = int(50)
int(0) After = int(50)
int(0) After = int(50)
Reference: http://php.net/manual/en/splfileobject.setmaxlinelen.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...