error_get_last

Supported Versions: PHP 5 >= 5.2.0, PHP 7, PHP 8
Get the last occurred error
<?php error_get_last(): ?array
<?php     {

        static::$reservedMemory = null;



        if (! is_null($error = error_get_last()) && $this->isFatal($error['type'])) {

            $this->handleException($this->fatalErrorFromPhpError($error, 0));

        }

    }
<?php     {

        $this->terminate();



        if (is_array($error = error_get_last())) {

            if (! in_array($error['type'], [E_ERROR, E_CORE_ERROR], true)) {

                return;

            }
<?php         $stmt = @db2_prepare($this->conn, $sql);



        if ($stmt === false) {

            throw PrepareFailed::new(error_get_last());

        }



        return new Statement($stmt);
<?php         $handle = @tmpfile();



        if ($handle === false) {

            throw CannotCreateTemporaryFile::new(error_get_last());

        }



        return $handle;
<?php     private function copyStreamToStream($source, $target): void

    {

        if (@stream_copy_to_stream($source, $target) === false) {

            throw CannotCopyStreamToStream::new(error_get_last());

        }

    }
<?php     private function writeStringToStream(string $string, $target): void

    {

        if (@fwrite($target, $string) === false) {

            throw CannotWriteToTemporaryFile::new(error_get_last());

        }

    }

}
<?php         $mode = $this->visibilityConverter->forFile($visibility);



        if ( ! @ftp_chmod($this->connection(), $mode, $location)) {

            $message = error_get_last()['message'];

            throw UnableToSetVisibility::atLocation($path, $message);

        }

    }
<?php         $object = @ftp_raw($this->connection(), 'STAT ' . $location);



        if (empty($object) || count($object) < 3 || substr($object[1], 0, 5) === "ftpd:") {

            throw UnableToRetrieveMetadata::create($path, $type, error_get_last()['message'] ?? '');

        }



        $attributes = $this->normalizeObject($object[1], '');
<?php         $fileSize = @ftp_size($connection, $location);



        if ($fileSize < 0) {

            throw UnableToRetrieveMetadata::fileSize($path, error_get_last()['message'] ?? '');

        }



        return new FileAttributes($path, $fileSize);
<?php             $result = @ftp_mkdir($connection, $location);



            if ($result === false) {

                $errorMessage = error_get_last()['message'] ?? 'unable to create the directory';

                throw UnableToCreateDirectory::atLocation($dirPath, $errorMessage);

            }
<?php         error_clear_last();



        if (($size = @file_put_contents($prefixedLocation, $contents, $this->writeFlags)) === false) {

            throw UnableToWriteFile::atLocation($path, error_get_last()['message'] ?? '');

        }



        if ($visibility = $config->get(Config::OPTION_VISIBILITY)) {
<?php         $stream = @fopen($prefixedLocation, 'w+b');



        if ( ! ($stream && false !== stream_copy_to_stream($contents, $stream) && fclose($stream))) {

            $reason = error_get_last()['message'] ?? '';

            throw UnableToWriteFile::atLocation($prefixedLocation, $reason);

        }
<?php         error_clear_last();



        if ( ! @unlink($location)) {

            throw UnableToDeleteFile::atLocation($location, error_get_last()['message'] ?? '');

        }

    }
<?php         unset($contents);



        if ( ! @rmdir($location)) {

            throw UnableToDeleteDirectory::atLocation($prefix, error_get_last()['message'] ?? '');

        }

    }
<?php         $contents = @file_get_contents($location);



        if ($contents === false) {

            throw UnableToReadFile::fromLocation($path, error_get_last()['message'] ?? '');

        }



        return $contents;