PHP Classes

brackets wont work

Recommend this page to a friend!

      Eval Math  >  All threads  >  brackets wont work  >  (Un) Subscribe thread alerts  
Subject:brackets wont work
Summary:can not use brackets
Messages:4
Author:Marcin Mucha
Date:2013-07-20 13:44:12
Update:2014-07-03 13:56:12
 

  1. brackets wont work   Reply   Report abuse  
Picture of Marcin Mucha Marcin Mucha - 2013-07-20 13:44:12
Hi,
I'have tried evaluate simple function:
echo $m->evaluate('-1*(5+2)');
but got error:
Undefined offset: -1
line 385
function last($n=1) {
return $this->stack[$this->count-$n];
}

without brackets everything is ok.
Has anyone tried this with brackets?

Martin

  2. Re: brackets wont work   Reply   Report abuse  
Picture of Jon Lennryd Jon Lennryd - 2014-07-03 13:41:47 - In reply to message 1 from Marcin Mucha
Hi, yes I get the same error.
I tried this: 2*(y+y*3)

And I got this warning:
Undefined offset: -1 [APP\Vendor\evalmath.php, line 384]

However, I get the correct answer returned!

  3. Re: brackets wont work   Reply   Report abuse  
Picture of Jon Lennryd Jon Lennryd - 2014-07-03 13:46:16 - In reply to message 2 from Jon Lennryd
Oh, I forgot to mention I have prepared evalmath by giving y a value, like 'y=12' for example.

evalmath.e('y=12');
$res = evalmath.e('2*(y+y*3)');

Gives me the warning:
Undefined offset: -1 [APP\Vendor\evalmath.php, line 384]

But $res contains the correct answer.

  4. Re: brackets wont work   Reply   Report abuse  
Picture of Jon Lennryd Jon Lennryd - 2014-07-03 13:56:12 - In reply to message 3 from Jon Lennryd
The people at stackoverflow as always has the solution: :)

stackoverflow.com/questions/4939711 ...