解析错误:语法错误,意外的'*' [英] Parse error: syntax error, unexpected '*'

查看:331
本文介绍了解析错误:语法错误,意外的'*'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码:

<?php

    function ci($principle, $rate, $time) {

        $ci = ($principle * (( (1 + $rate / 100) ** $time) - 1));
        echo $ci;

    }

?>
<?php
    echo ci(10,10,10);
?>

当我运行它时,它出现以下错误

And when I am running it, it gives the following error

解析错误:语法错误,第4行D:\ Xampp \ htdocs \ php \ functions.php中出现意外的'*'

Parse error: syntax error, unexpected '*' in D:\Xampp\htdocs\php\functions.php on line 4

请告诉我第4行($ci = ($principle * (((1+$rate/100)**$time)-1));)有什么错误?

Please tell me what's the error in line 4 ($ci = ($principle * (((1+$rate/100)**$time)-1));) ?

推荐答案

您的语法正确无误.问题是您的PHP版本.在 ** 运算符中引入了PHP 5.6,您可能会在下面找到一些东西.

Your syntax as it is, is correct. The problem is your PHP version. The ** operator was introduced in PHP 5.6 and you probably have something below.

因此,要么更新您的PHP,要么使用 pow() .

So either update your PHP or use pow().

这篇关于解析错误:语法错误,意外的'*'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆