Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Zephir: ParseException

I am trying to compile the below code in zephir language and it gives me Parse error. I am not sure what am I doing wrong.

public static function calculateDiscrepancy(tpImpr, liImpressions, defaults) {
        var numeratorx = 1-(tpImpr + defaults);
        if numeratorx != 0 && liImpressions != 0 {
              return (double)(numeratorx / liImpressions) * 100;
        }else{
            return 0;
        }
}

Error:

Zephir\ParseException: Syntax error in /var/www/vhosts/app/advertisingcalculator.zep on line 58

 var numeratorx = 1-(tpImpr + defaults);
 -----------------------^

Any Ideas?



33.6k
Accepted
answer
edited Apr '14

Hi You can try, Replace code the content following

var numeratorx = 1-(tpImpr + defaults);

To

var numeratorx;
let numeratorx = 1-(tpImpr + defaults);

That worked thanks!