帮我发现错误 [英] Help me spot the mistake

查看:64
本文介绍了帮我发现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编程说如果你在[link]和[/ link]之间输入文字,它会输入一个链接。这工作之前,但现在链接不起作用。我需要它在PHP中。 Plz帮我发现错误。 ($ ms是文本)

例如[link] example.com [/ link] 输入 =< a href =https://example.com> https://example.com< / A> 输出到数据库



固定



必须 +6 -6 不是+3和-3

我太笨了br $> b $ b

必须是这样的:

I have programmed that if you enter text in between [link] and [/link], it would enter a link. This worked before but now the link doesn't work. I need it in PHP. Plz help me spot the mistake. ($ms is the text)
e.g [link]example.com[/link] input = < a href="https://example.com">https://example.com< /a> output to database

FIXED

It had to be +6 and -6 not +3 and-3
I'm sooooo dumb

Has to be this:

$link = substr($ms, (strpos($ms, "[link]")+6), (strpos($ms, "[/link]")-strpos($ms, "[link]")-6));





不是:



Not:

$link = substr($ms, (strpos($ms, "[link]")+3), (strpos($ms, "[/link]")-strpos($ms, "[link]")-3));





我尝试过:





What I have tried:

$ms = $row['inp'];
if(strpos($ms, "[link]") !== false and strpos($ms, "[/link]") !== false) {
	$link = substr($ms, (strpos($ms, "[link]")+3), (strpos($ms, "[/link]")-strpos($ms, "[link]")-3));
	$ms = str_replace("[link]", "<a href="http://$link" class="url" target="_blank">http://", $ms);
	$ms = str_replace("[/link]", "</a>", $ms);
}

推荐答案

ms是文本)

例如[link] 示例.com [/ link] 输入 =< a href =https://example.com> https://example.com< / A> 输出到数据库



固定



必须 +6 -6 不是+3和-3

我太笨了br $>


必须是这样的:

ms is the text)
e.g [link]example.com[/link] input = < a href="https://example.com">https://example.com< /a> output to database

FIXED

It had to be +6 and -6 not +3 and-3
I'm sooooo dumb

Has to be this:


link = substr(
link = substr(


ms,(strpos(
ms, (strpos(


这篇关于帮我发现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆