我想在 Codeigniter 中创建自己的数字格式化程序助手。但是当我调用我的函数时,它显示错误:
严重性:通知
消息:遇到格式不正确的数值
这是我的辅助函数:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('test_method'))
{
function test_method($var = '')
{
return number_format( (float) $var, 0, ',', '.');
}
}
Run Code Online (Sandbox Code Playgroud)
当我在视图中执行时:
<?php echo test_method($price) ?>
Run Code Online (Sandbox Code Playgroud)
我收到了上述通知。如何修复它?