Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include my own mb_string functions or use PHP's defaults?

For a public app - do you think it's a good idea to assume the mb_string extension is enabled on all servers (or almost all, like 95%)?

Are there hosts out there that disable this extension?

like image 410
Alex Avatar asked Nov 21 '25 00:11

Alex


1 Answers

I think most have it enabled by default but I've known a few hosting providers that don't, and who also then refused to enable it (never did get a good reason out of them).

If you want all users to be able to install the app on their server without any changes then you'll probably want to roll your own set of functions.

However it might be a better solution to make mb_string a pre-requisite of your app (and perhaps test for it's existence in the installation script) then you'd be able to save yourself that extra work, while still providing a satisfactory user experience.

If you take Drupal as an example of a public app, they actually roll their own functions (e.g. drupal_substr() and drupal_strlen()), in which they test for the existence of the mb_string extension and make the decision on how to run the function based on that.

like image 71
Clive Avatar answered Nov 22 '25 15:11

Clive



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!