phps mb_ereg 函数可以安全使用吗(由于 ereg 已被弃用)?
我只是想调整我的代码以兼容 php 5.3 (6.0)。 所以我想将对 ereg 函数的所有调用替换为相应的 preg 函数。
但后来我发现 mb_ereg 函数尚未被标记为已弃用。所以我只是想知道依靠他们是否可以节省?是否知道它们也将很快被宣布弃用,或者甚至是文档中的缺陷?
I just wanted to adapt my code to be compatible to php 5.3 (6.0).
So i wanted to replace all the calls to the ereg functions with the corresponding preg functions.
But then I saw that the mb_ereg function haven't been marked as deprecated. So I am just wondering if it is save to rely on them? Is something known that they will also been declared deprecated soon or is it even a flaw in the documentation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不会依赖他们。 preg 函数更快、更高效、更强大并且简单地支持 UTF8。我建议使用 preg 函数来满足您的所有正则表达式需求。
但要直接回答您的问题,似乎
mb_ereg
并未被弃用......I wouldn't depend on them. The preg functions are faster, more efficient, much more powerful and naively support UTF8. I would recommend using the preg functions for all of your regex needs.
But to directly answer your question, it does not appear that
mb_ereg
is deprecated...如果您想快速解决问题并节省时间,可以将所有
ereg
替换为mb_ereg
。mb_ereg
未标记为已弃用,它是ereg
的直接替代品。你可以依赖它一段时间或更长时间,我们不知道。但如果您有一些空闲时间,我认为应该更好,正如 ircmaxell 建议的那样,将所有
mb_ereg
替换为preg
。You can replace all of your
ereg
withmb_ereg
if you want quick solution and save your time.mb_ereg
is not marked as deprecated and it is a direct replacement forereg
.You can rely on it for certain time or longer, we don't know. But if you have some free time, I think should be better, as ircmaxell suggest, to replace all of your
mb_ereg
withpreg
.mb_ereg 并未被弃用,但我不会依赖它,因为它可能会被弃用。此外,PCRE 通过
u
修饰符支持 UTF-8。请参阅此答案。mb_ereg
is not deprecated, but I wouldn't rely on it because it probably is going to be. Besides, PCRE supports UTF-8 via theu
modifier. See this answer.