iconv_strlen函数导致执行超时,在MAMP上运行
有人在运行 MAMP 时遇到 iconv_strlen 函数的问题吗?
Has anyone had issues with the iconv_strlen function while running MAMP?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我一直遇到超时问题,但没有抛出任何异常。我正在开发一个 Zend Framework 网站。通过深入跟踪调试器,我将问题追溯到 iconv_strlen 的使用。它不会在任何奇怪的字符串上调用,它是一个用于验证主机名的简单函数。
为了验证这个问题,我尝试了一个简单的 iconv_strlen("test", 'UTF-8');这会导致错误出现 - 浏览器中无休止地旋转加载程序,但没有错误日志消息,并且脚本超出了最大执行时间。看来这是这个版本的PHP中的一个未捕获的大事件。
我的同事发现这篇文章可能会解决这个问题。我使用的 Mac OS X 计算机已更新至最新的 Snow Leopard,即 10.6。这似乎是一个已知的错误,如果您构建自己的 php 或使用内置的 Apple 版本或使用端口,则有一个解决方法。
2009 年 11 月 5 日
长话短说,您可以深入研究使用上述补丁重新编译您自己的 php,但这首先就违背了 MAMP 的要点。
最快的解决方案就是永远不要使用 iconv_strlen() (或任何 iconv_ 函数) - 如果您使用 Zend Framework,这不是一个选项 - 或者恢复 MAMP 以使用 php 5.2。
在 MAMP 开始包含 php 源文件并提供一种方法来轻松重新编译与所有必要的库捆绑在一起的 php 之前,这必然仍然是该包的限制。 MAMP 工作得很好,直到您需要重新编译 php。当这种情况发生时,简单地使用端口会容易得多。
I have been having a timeout issue with it, but not with any exceptions being thrown. I'm working on a Zend Framework site. By following the debugger deep into the guts, I tracked the problem down to the use of iconv_strlen. It's not being called on any strange string, it's a simple function being used to validate a hostname.
To verify the issue, I tried a simple iconv_strlen("test", 'UTF-8'); This causes the error to come up - endless spinning loader in browser but no error log message, and the script goes beyond the max execution time. It seems that this is an uncaught big in this version of PHP.
My colleague found this article which might address the issue. I'm on a Mac OS X machine updated to the latest Snow Leopard, which is 10.6. It seems that this is a known bug and there is a workaround if you build your own php or use the built in Apple version or use ports.
05 Nov 2009
Long story short, you can delve into recompiling your own php with the above patch, but this kind of defeats the point of MAMP in the first place.
The quickest solution is simply either never use iconv_strlen() (or any of the iconv_ functions) - and this is not an option if you use Zend Framework - or else revert MAMP to use php 5.2.
Until MAMP begins including php source files and providing a method by which to easily recompile the php bundled with all of the necessary libraries, this is will necessarily remain a limitation of the package. MAMP works great until you get to the point where you need to recompile php. When that happens, it's far easier to simply use ports.
如果有人仍然遇到这个问题,我为此苦苦挣扎了很长时间,但在 OSX Lion 上升级到最新版本的 MAMP Pro 似乎对我有用。
In case anyone is still having this issue, I struggled for ages with this, but upgrading to the very latest version of MAMP Pro on OSX Lion seemed to work for me.
wbond,你有点混淆了。 MAMP 1.9.4 100% 正常工作。从 1.9.5 到 2.0.1 的任何 MAMP 版本都包含“iconv”问题。另外,我在 MAMP 2.0.1 中的 PHP 5.3.6 中测试了您的解决方案,但它不起作用。唯一的解决方案是回滚到 MAMP 1.9.4 或使用最新的 MAMP 但将 PHP 回滚到 5.2.x。
wbond, you have it a bit mixed up. MAMP 1.9.4 works 100% fine. It’s any version of MAMP from 1.9.5 to 2.0.1 that contains the “iconv” issue. Also, I tested your solution in PHP 5.3.6 in MAMP 2.0.1 and it doesn’t work. The only solution is roll back to MAMP 1.9.4 or use latest MAMP but roll PHP back to 5.2.x.
根据 MAMP 论坛,2.x 版的新更新( 2.0.2 于 2011 年 8 月 17 日发布)解决了 iconv 问题。是的!
According to the MAMP forums, the new update to version 2.x (2.0.2 released on August 17, 2011) resolves the iconv issue. Yes!