PHP未定义常量PHP_ROUND_HALF_DOWN [英] PHP Undefined Constant PHP_ROUND_HALF_DOWN

查看:62
本文介绍了PHP未定义常量PHP_ROUND_HALF_DOWN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理的项目中有一些PHP代码,该代码使用PHP的round函数。在我的本地主机上,我的mode参数周围没有任何引号,仅表示为PHP_ROUND_HALF_DOWN。但是,当推送到我的服务器时,我收到错误消息:

I have some PHP code in a project I'm working on that uses PHP's round function. On my localhost, I don't include any quotes around my mode argument, stating it as just PHP_ROUND_HALF_DOWN. However, when pushing to my server I get the error message:

Use of undefined constant PHP_ROUND_HALF_DOWN - assumed 'PHP_ROUND_HALF_DOWN'
Warning (2): Wrong parameter count for round() [APP/views/helpers/time_left.php, line 14]

现在,当我将单引号添加到mode参数时,第一个错误消失了,但是仍然存在错误的参数计数。我按如下方式调用该函数:

Now, when I add the single quotes to the mode argument, the first error goes away, however the "wrong parameter count" remains. I'm calling the function as follows:

$days = round(($difference/$day), 0, PHP_ROUND_HALF_DOWN);

感谢所有帮助!

推荐答案

PHP 5.3中添加了取整模式。 。确保您至少运行该版本。

The rounding mode was added in PHP 5.3. Make sure you're running at least that version.

通过在PHP文件中放置以下内容,可以查看正在运行的版本:

You can see which version you're running by placing the following in a PHP file:

var_dump(phpversion());

这篇关于PHP未定义常量PHP_ROUND_HALF_DOWN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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