定制 cognito/evalmath 二次开发

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

邮箱: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.1k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固