SplFileObject::getFlags

(PHP 5 >= 5.1.0, PHP 7)
Gets flags for the SplFileObject
public int SplFileObject::getFlags ( void )

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

Returns:

Returns an integer representing the flags.

Examples:
SplFileObject::getFlags() example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?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:

Not skipping empty lines
Skipping empty lines

See also:

SplFileObject::setFlags() -

doc_php
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.