SplFileObject::setMaxLineLen
(PHP 5 >= 5.1.0, PHP 7, PHP 8)
SplFileObject::setMaxLineLen — Set maximum line length
说明
public SplFileObject::setMaxLineLen(int
$maxLength
): voidSets the maximum length of a line to be read.
参数
-
maxLength
-
The maximum length of a line.
返回值
没有返回值。
错误/异常
Throws DomainException when
maxLength
is less than zero.
范例
示例 #1 SplFileObject::setMaxLineLen() example
<?php
$file = new SplFileObject("lipsum.txt");
$file->setMaxLineLen(20);
foreach ($file as $line) {
echo $line . "\n";
}
?>
Contents of lipsum.txt
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis nec sapien felis, ac sodales nisl. Nulla vitae magna vitae purus aliquet consequat.
以上例程的输出类似于:
Lorem ipsum dolor s it amet, consectetu r adipiscing elit. Duis nec sapien fel is, ac sodales nisl . Nulla vitae magna v itae purus aliquet consequat.

User Contributed Notes
There are no user contributed notes for this page.
备份地址:http://www.lvesu.com/blog/php/splfileobject.setmaxlinelen.php