Reputation: 235
I have enabled mbstring in my php.ini.It even shows in phpinfo().But still I am getting this error in yii2.
PHP Fatal Error 'yii\base\ErrorException' with message 'Call to undefined function yii\helpers\mb_strlen()
Upvotes: 0
Views: 3086
Reputation: 33548
As @TomaszKane said in comment, mb_strlen()
is native PHP function, so you need to call it as mbstrlen()
without specifying the namespace.
Official documentation:
Also take a look at yii\helpers\StringHelper, mb_strlen()
is used in several places. For example, if you are looking for byte length, there is special method byteLength(), you can call it like that:
use yii\helpers\StringHelper;
...
StringHelper::byteLength($string);
It's basically syntactic sugar of mb_strlen()
.
Upvotes: 1