YoastSEO_Vendor\GuzzleHttp\Psr7
try_fopen() Yoast 1.0
Safely opens a PHP stream resource using a filename.
When fopen fails, PHP normally raises a warning. This function adds an error handler that checks for errors and throws an exception instead.
Хуков нет.
Возвращает
resource.
Использование
try_fopen( $filename, $mode );
- $filename(строка) (обязательный)
- File to open
- $mode(строка) (обязательный)
- Mode used to open the file
Код try_fopen() try fopen Yoast 15.6.2
function try_fopen($filename, $mode)
{
$ex = null;
\set_error_handler(function () use($filename, $mode, &$ex) {
$ex = new \RuntimeException(\sprintf('Unable to open %s using mode %s: %s', $filename, $mode, \func_get_args()[1]));
});
$handle = \fopen($filename, $mode);
\restore_error_handler();
if ($ex) {
/** @var $ex \RuntimeException */
throw $ex;
}
return $handle;
}