Dutch PHP Conference 2025 - Call For Papers

SplFileObject::setMaxLineLen

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

SplFileObject::setMaxLineLenSet maximum line length

Опис

public SplFileObject::setMaxLineLen(int $maxLength): void

Sets 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.

Прогляньте також

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top