PHP / HTML是否有办法在浏览器中打开链接?
抱歉,如果问题有些混乱,我的问题是与我当前的代码:
$pattern = '/(([\w+]+\:\/\/)?([\w\d-]+\.)*[\w-]+[\.\:]\w+([\/\?\=\&\#.]?[\w-]+)*\/?)/m';
$str = file_get_contents('notiz.txt');
echo nl2br (preg_replace($pattern, "<a href='?url=$1' >$1</a>", $str))
每个链接都在PHP桌面应用程序中打开,但是我希望它在浏览器中打开(Edge,Chrome等)。我仍然是PHP和HTML的新手。
编辑:这是
Sorry if the question is a bit confusing, my problem is that with my current code:
$pattern = '/(([\w+]+\:\/\/)?([\w\d-]+\.)*[\w-]+[\.\:]\w+([\/\?\=\&\#.]?[\w-]+)*\/?)/m';
$str = file_get_contents('notiz.txt');
echo nl2br (preg_replace($pattern, "<a href='?url=$1' >$1</a>", $str))
every link is opened in the PHP desktop app, but i want it to open in the browser (Edge, Chrome, whatever). I'm still pretty new to PHP and html.
Edit: Here's a screenshot ofenter image description here PHP Desktop Chrome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在浏览器中,您需要一些帮助形式JavaScript。仅将脚本放在下面
&lt;/body&gt;标签。
加载页面并渲染函数 openlinks 正在寻找文档中的所有&gt; a&gt; 标签,并将打开每个带有 window.open()的新标签。
In the browser you will need some help form JavaScript. Put the script below just
before the </body> tag.
When the page is loaded and rendered the function OpenLinks is looking for all <A> tags in your document and will open each one in a new tab with window.open().
经过一些朋友的研究和帮助,我找到了一种有效的方法。我的问题可能也令人困惑。这是工作代码:
这确保在新窗口中使用Google Chrome在我单击时打开链接。
无论如何,感谢您的帮助。
After some research and help of a friend i found a way that works. My question was probably confusing too. Here's the working code:
This makes sure to use Google Chrome in a new window to open the link when i click on it.
Thanks for all your help anyways.