php8.5
Home/ Manual/ spl / splfileobject/ SplFileObject::getFlags

SplFileObject::getFlags

PHP function Edit on GitHub ✎

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

Gets flags for the SplFileObject

Description

SplFileObject::getFlags(): int

Gets the flags set for an instance of SplFileObject as an int.

Parameters Parameters

Return Values

Returns an int representing the flags.

Examples

SplFileObject::getFlags example

php
<?php
$file = new SplFileObject(__FILE__, "r");

if ($file->getFlags() & SplFileObject::SKIP_EMPTY) {
    echo "Skipping empty lines\n";
} else {
    echo "Not skipping empty lines\n";
}

$file->setFlags(SplFileObject::SKIP_EMPTY);

if ($file->getFlags() & SplFileObject::SKIP_EMPTY) {
    echo "Skipping empty lines\n";
} else {
    echo "Not skipping empty lines\n";
}
?>

The above example will output something similar to:

output
Not skipping empty lines
Skipping empty lines

See Also

  • SplFileObject::setFlags

Source: reference/spl/splfileobject/getflags.xml · from the official PHP manual (php/doc-en)