承接 waughj/math-parser 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

waughj/math-parser

Composer 安装命令:

composer require waughj/math-parser

包简介

Simple Lisp-like math parser.

关键字:

README 文档

README

Simple Lisp-like math parser.

Example

use WaughJ\MathParser\MathParser;

$math = new MathParser();
echo( $math->parse( '(+ 2 2)' ) );

Prints "4".

To use a different parser:

use WaughJ\MathParser\MathParser;

$math = new MathParser( new LisphpParser( [ ',' ] ) );
echo( $math->parse( '(*,2,5)' ) );

Prints "10".

To create a new custom function:

use WaughJ\MathParser\MathParser;
use WaughJ\MathParser\MathParserExceptionInvalidFunctionCall;

$math = new MathParser();
$math->addFunction
(
    'double',
    function( array $args )
    {
        $arg_count = count( $args );
        if ( $arg_count < 1 )
        {
            throw new MathParserExceptionInvalidFunctionCall
            (
                "Call to function “double” given no arguments. Needs at least 1."
            );
        }
        return array_shift( $args ) * 2;
    }
);
echo( $math->parse( '(double 222)' ) );

Prints "444".

Changelog

0.1.0

  • Initial stable version.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2019-04-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固