SplFileObject::setMaxLineLen()函数是PHP中的标准PHP库(SPL)的内置函数,用于设置行长度的最大长度。
用法:
void SplFileObject::setMaxLineLen( $len )
参数:该函数接受单个参数$len,该参数用于指定行的最大长度。
Return values:此函数返回行的最大长度。默认值为0。
下面的程序演示了PHP中的SplFileObject::setMaxLineLen()函数:
程序1:
<?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()); 
  
?>输出:
int(0) int(20)
程序2:
<?php 
  
// Create an Array 
$GFG = array( 
    "dummy.txt", 
    "gfg.txt", 
    "frame.txt"
    ); 
  
// Creating Spl Object 
foreach ($GFG as &$arr)  
{ 
    // Create an SplFile Object 
    $gfg = new SplFileObject($arr); 
  
    // Print Length before 
    var_dump($gfg->getMaxLineLen()); 
  
    // Set length  
    $gfg->setMaxLineLen(50); 
    echo "After = "; 
    // Print length after 
    var_dump($gfg->getMaxLineLen()); 
  
    echo "</br>"; 
    } 
?>
输出:
int(0) After = int(50) int(0) After = int(50) int(0) After = int(50)
参考: http://php.net/manual/en/splfileobject.setmaxlinelen.php
相关用法
- PHP SplFileObject eof()用法及代码示例
- PHP SplFileObject ftell()用法及代码示例
- PHP SplFileObject fstat()用法及代码示例
- PHP SplFileObject ftruncate()用法及代码示例
- PHP SplFileObject fread()用法及代码示例
- PHP SplFileObject rewind()用法及代码示例
- PHP SplFileObject seek()用法及代码示例
- PHP SplFileObject fputcsv()用法及代码示例
- PHP SplFileObject fwrite()用法及代码示例
- PHP SplFileObject fgetss()用法及代码示例
- PHP SplFileObject fgets()用法及代码示例
- PHP SplFileObject fgetc()用法及代码示例
- PHP SplFileObject getMaxLineLen()用法及代码示例
- PHP SplFileObject flock()用法及代码示例
- PHP SplFileObject current( )用法及代码示例
注:本文由纯净天空筛选整理自R_Raj大神的英文原创作品 PHP | SplFileObject setMaxLineLen() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
