定制 langleyfoxall/math_eval 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

langleyfoxall/math_eval

最新稳定版本:v2.0.0

Composer 安装命令:

composer require langleyfoxall/math_eval

包简介

✖️➕➖➗ `math_eval` safely evaluates mathematical expressions

README 文档

README

Build Status Coverage Status StyleCI Packagist

This PHP package provides a math_eval helper function, that allows safe evaluation of mathematical expressions, without the use of the potentially dangerous eval function.

Installation

The math_eval package can be easily installed using Composer. Just run the following command from the root of your project.

composer require "langleyfoxall/math_eval"

If you have never used the Composer dependency manager before, head to the Composer website for more information on how to get started.

Usage

To evaluate a basic mathematical expression, just pass its string representation to the math_eval function.

Here are some basic usage examples:

$two = math_eval('1 + 1');
$three = math_eval('5 - 2');
$ten = math_eval('2 * 5');
$four = math_eval('8 / 2');

It is also possible to pass expression variables. See the examples below.

$ten = math_eval('a + b', ['a' => 7, 'b' => 3]);
$fifteen = math_eval('x * y', ['x' => 3, 'y' => 5]);

Credit

This package makes use of the mossadal/math-parser package.

统计信息

  • 总下载量: 657.25k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 42
  • 点击次数: 3
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 41
  • Watchers: 0
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0-only
  • 更新时间: 2018-11-01