Skip to content

Instantly share code, notes, and snippets.

@antimech
Last active November 22, 2023 08:39
Show Gist options
  • Save antimech/73b8a8788e7c906de2f76f8f1104f021 to your computer and use it in GitHub Desktop.
Save antimech/73b8a8788e7c906de2f76f8f1104f021 to your computer and use it in GitHub Desktop.
Калькулятор с использованием библиотеки chriskonnertz/string-calc. $ php calc.php и введите ваше выражение, например: 1+2*4+(4*4)
#!/usr/bin/env php8.1
<?php
// $ composer require chriskonnertz/string-calc:^2.0.0
require __DIR__ . '/vendor/autoload.php';
$stringCalc = new ChrisKonnertz\StringCalc\StringCalc();
$term = trim(fgets(STDIN)); // reads one line from STDIN
$result = $stringCalc->calculate($term);
echo $term . '=' . $result . "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment