包含我自己的 mb_string 函数还是使用 PHP 的默认值?
对于公共应用程序 - 您认为假设在所有服务器(或几乎所有服务器,例如 95%)上启用 mb_string 扩展是一个好主意吗?
是否有主机禁用此扩展?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为大多数默认情况下都会启用它,但我知道一些托管提供商没有启用它,并且他们也拒绝启用它(从来没有从他们那里得到充分的理由)。
如果您希望所有用户都能够在不进行任何更改的情况下在其服务器上安装该应用程序,那么您可能需要推出自己的一组功能。
然而,将
mb_string
作为应用程序的先决条件(也许可以测试它是否存在于安装脚本中)可能是一个更好的解决方案,这样您就可以节省额外的工作,同时仍然提供令人满意的用户体验。如果您将 Drupal 作为公共应用程序的示例,它们实际上会推出自己的函数(例如
drupal_substr()
和drupal_strlen()
),其中他们测试mb_string
扩展是否存在,并根据该扩展决定如何运行该函数。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()
anddrupal_strlen()
), in which they test for the existence of themb_string
extension and make the decision on how to run the function based on that.