note 124444 deleted from function.file-get-contents by cmb

From: Date: Wed, 27 Nov 2019 11:57:08 +0000
Subject: note 124444 deleted from function.file-get-contents by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213268@lists.php.net to get a copy of this message
Note Submitter: Sergey Podgornyy ---- file_get_contents() could throws an ErrorException, but isn't documented. I found it only for case, when file name is empty: Warning: file_get_contents(): Filename cannot be empty Of course, for this specific case if could be prevented by checking string: <?php if (empty($fileName)) { throw new \LogicException('File name could not be empty'); } $fileContent = \file_get_contents($fileName); ?> But as it is not described in the documentation which Exceptions and in which cases could be thrown, it is forcing people like me to use outdated @ operator, or wrap all code execution with catch (\Throwable $e)

« previous php.notes (#213268) next »