cognito/evalmath 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

cognito/evalmath

最新稳定版本:1.2.0

Composer 安装命令:

composer require cognito/evalmath

包简介

Evaluate mathematical and logic equations

README 文档

README

PHP EvalMath with Logic equations

Build Status

This package is a composer-aware way to add the EvalMath package by Miles Kaufmann. More information on the original at https://www.phpclasses.org/package/2695-PHP-Safely-evaluate-mathematical-expressions.html

Added to this is the ability to evaluate logic equations, as per the code by Lee Eden posted at https://www.phpclasses.org/discuss/package/2695/thread/4/

To use:

<?php
	$math = new \Cognito\EvalMath\EvalMath;
	// basic evaluation:
	$result = $math->evaluate('2 + 2');
	// supports: order of operation; parentheses; negation; built-in functions
	$result = $math->evaluate('-8(5/2)^2 * (1 - sqrt(4)) - 8');
	// create your own variables
	$math->evaluate('a = e^(ln(pi))');
	// or functions
	$math->evaluate('f(x,y) = x^2 + y^2 - 2x*y + 1');
	// and then use them
	$result = $math->evaluate('3*f(42,a)');

	// Use the equations in logic strings
	$result = $math->evaluate('2 + 2 = 4'); // true
	$result = $math->evaluate('2 + 2 < 4'); // false
	$result = $math->evaluate('2 + 2 >= 4'); // true

	// Use dates as well, they are converted to seconds from epoch
	$result = $math->evaluate('date(y,m,d,h,m)');

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2019-01-07