Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andreiigna/safe-eval
Safely evaluate code expressions in PHP
https://github.com/andreiigna/safe-eval
Last synced: 5 days ago
JSON representation
Safely evaluate code expressions in PHP
- Host: GitHub
- URL: https://github.com/andreiigna/safe-eval
- Owner: AndreiIgna
- Created: 2019-04-26T13:08:03.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-05-02T09:50:55.000Z (over 5 years ago)
- Last Synced: 2024-08-10T11:59:39.699Z (3 months ago)
- Language: PHP
- Size: 8.79 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Safe Eval
Safely evaluate code expressions in PHP, without using `eval`. [ExpressionLanguage](https://github.com/symfony/expression-language) is most likely better at this, but SafeEval still supports PHP 5, for the projects that need it.
## Usage
```php
use Layered\SafeEval\SafeEval;$safeEval = new SafeEval;
echo $safeEval->eval('1 + 2');
var_dump($safeEval->eval('1 or 0'));
```