PHP preg_replace phpBB 中的 URI
我正在尝试替换从外部页面的数据库检索的某些 phpBB 论坛帖子内容中的某些图像 URI。
preg_replace('/((https?|ftp).*\.(gif|png|jpg|jpeg))/i', '<img src="$1" alt "" />','http://somesite.com/image.png awordcontainingpng');
以上效果很好并且符合预期。
问题是,当我尝试将相同的结果应用于 MySQL 结果时,没有任何匹配。当我删除转义点时,匹配似乎有效,
例如:
preg_replace('/((https?|ftp).*(gif|png|jpg|jpeg))/i', '<img src="$1" />',$phpbb_post);
但这不好。数据是 BLOB 类型 - 我不知道这是否有区别。有人能帮我解决这个问题吗?
谢谢。
I'm trying to replace some image URI's in some phpBB forum post content retrieved from the DB for an external page.
preg_replace('/((https?|ftp).*\.(gif|png|jpg|jpeg))/i', '<img src="$1" alt "" />','http://somesite.com/image.png awordcontainingpng');
The above works well and as expected.
The thing is, when I try to apply the same to the MySQL result, nothing gets matched. Matches seem to work when I remove the escaped dot
E.g.:
preg_replace('/((https?|ftp).*(gif|png|jpg|jpeg))/i', '<img src="$1" />',$phpbb_post);
But that's no good. The data is BLOB type - I don't know if that makes a difference. Could anyone help me with this?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在PHPBB中,当图像保存到数据库中时,它们是完全编码的。这意味着点
.
被替换为.
。In PHPBB, when the images are saved into the database, they are totally encoded. This means that the dot
.
is replaced by a.
.当您直接从 MYSQL 加载图像时,您会这样做,因此
假设您可以检索图像数据,然后将其保存为 display.php
并从您的 HTML 中调用此
when you load Image directly from MYSQL you do it this way
so assuming you can retrieve image data follow it with this and save files as display.php
and from your HTML call this