We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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?



58.4k
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!