https://github.com/andreiigna/safe-eval
Safely evaluate code expressions in PHP
https://github.com/andreiigna/safe-eval
Last synced: 4 months 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 (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-02T09:50:55.000Z (about 6 years ago)
- Last Synced: 2025-01-06T10:47:05.893Z (6 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'));
```