1
votes

I want to use this php library "Math-php-master" in my php script.

it is using namespaces.

My script is outside the library folder and the folder for the library is "MathPHP"

There is a php file "Finance.php" which I want to access.

path is "MathPHP/Finance.php". finance.php is using namespace MathPHP

and there is function irr() inside Finance.php which I need.

My code for accessing in my script is below:

include 'MathPHP/Finance.php'; 
use MathPHP\Finance;

$s = new MathPHP\Finance;

$val = $s->irr(array);

but when I run the script it is giving error "Uncaught Error: Class 'MathPHP\Finance' not found"

I tried everything, I tried the code given on github by the author but it is not working at all

link to the library on github: https://github.com/markrogoyski/math-php

Please help me.

thanks

1

1 Answers

0
votes

You have not gone through the effort of readying the readme on how to use the library. In PHP most projects use composer and its autoloading to load classes.

Install composer if you do not have it https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx

In short as the documentation suggests do

php composer.phar require markrogoyski/math-php:0.*

And in your code

require_once(__DIR__ . '/vendor/autoload.php');

use MathPHP\Finance;


// the rest of the code here