I’m working with PHP 8.3 and have encountered a puzzling issue regarding the mb_internal_encoding()
function. When using PHP through an Apache web server, everything works seamlessly. However, when I switch to the command line interface (CLI), I receive the following error:
PHP Fatal error: Uncaught Error: Call to undefined function mb_internal_encoding()
Interestingly, I didn’t face this problem in PHP 8.2, and it seems like the mb_internal_encoding()
function is not recognized in the CLI environment with PHP 8.3. I’ve checked my PHP version, and it’s indeed 8.3. Is there something specific I need to configure or enable to make this function available in the CLI as well?
Any insights or suggestions on how to resolve this issue would be greatly appreciated.
2
Answers
It looks like there is some trouble with Debian and PHP 8.3
Anyways. I switched back to PHP 8.2.13
sudo update-alternatives --set php /usr/bin/php8.2
Now mb_internal_encoding is workling again.
And
php -m | grep mb
returns
as expected
mb_internal_encoding is supported in PHP 8. So, if it fails for you, then you do not have its extension,
php-mbstring
properly installed. You will need to identify which php.ini is being used by your CLI PHP and then make sure this extension is installed and enabled for that, see more here: https://www.php.net/manual/en/mbstring.installation.php