davidlienhard / functioncaller
🐘 php library to call functions and catch triggered errors
Installs: 8 590
Dependents: 4
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 1
Type:libary
Requires
- php: ^8.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-11 14:59:28 UTC
README
🐘 php library to call functions and catch triggered errors
Setup
You can install through composer
with:
composer require davidlienhard/functioncaller:^1
Note: davidlienhard/functioncaller requires PHP 8.0
Example
<?php declare(strict_types=1); use DavidLienhard\FunctionCaller\Call as FunctionCaller; $caller = new FunctionCaller("file", "testfile.txt"); // create caller instance $result = $caller->getResult(); // get result from call if ($result === false) { // check if function has return false $errstr = $caller->getLastError()?->getErrstr(); // get error string $errno = $caller->getLastError()?->getErrno(); // get error number throw new \Exception("unable to read file 'testfile.php': ".$errstr." (".$errno.")"); }
License
The MIT License (MIT). Please see LICENSE for more information.