CI4 controller error with built-in php class (intl) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: CI4 controller error with built-in php class (intl) (/showthread.php?tid=77081) |
CI4 controller error with built-in php class (intl) - nmaa3003 - 07-17-2020 this my code PHP Code: 46 public function view_receipt($id) at line 53 i try to use NumberFormatter class which is built-in php by enabling intl extension. working fine in php CLI. but issue an error when use it in controller. Quote:Error RE: CI4 controller error with built-in php class (intl) - jreklund - 07-17-2020 Add \ in front of it to use native PHP-functions. \NumberFormatter RE: CI4 controller error with built-in php class (intl) - nmaa3003 - 07-17-2020 (07-17-2020, 02:44 AM)jreklund Wrote: Add \ in front of it to use native PHP-functions.thanks a lot. as far i remember, in ci3 we dont hv to put it. *note to other: make sure to put \ to both class name like this -> $credit_term = new \NumberFormatter("en", \NumberFormatter::SPELLOUT); RE: CI4 controller error with built-in php class (intl) - jreklund - 07-17-2020 That's correct. CI3 don't use namespaces, so everything are global. Now it will try finding the closes match first. RE: CI4 controller error with built-in php class (intl) - tgix - 07-17-2020 Just to add: a good IDE will provide you with tons of help when it comes to namespacing stuff. |