<legend id='m1tzG'><style id='m1tzG'><dir id='m1tzG'><q id='m1tzG'></q></dir></style></legend>

    <tfoot id='m1tzG'></tfoot>
    <i id='m1tzG'><tr id='m1tzG'><dt id='m1tzG'><q id='m1tzG'><span id='m1tzG'><b id='m1tzG'><form id='m1tzG'><ins id='m1tzG'></ins><ul id='m1tzG'></ul><sub id='m1tzG'></sub></form><legend id='m1tzG'></legend><bdo id='m1tzG'><pre id='m1tzG'><center id='m1tzG'></center></pre></bdo></b><th id='m1tzG'></th></span></q></dt></tr></i><div id='m1tzG'><tfoot id='m1tzG'></tfoot><dl id='m1tzG'><fieldset id='m1tzG'></fieldset></dl></div>

    <small id='m1tzG'></small><noframes id='m1tzG'>

      • <bdo id='m1tzG'></bdo><ul id='m1tzG'></ul>
    1. PHP - 在文本中查找链接的函数

      PHP - Function To Find Links In Text(PHP - 在文本中查找链接的函数)
      <tfoot id='2u5mc'></tfoot>

      <i id='2u5mc'><tr id='2u5mc'><dt id='2u5mc'><q id='2u5mc'><span id='2u5mc'><b id='2u5mc'><form id='2u5mc'><ins id='2u5mc'></ins><ul id='2u5mc'></ul><sub id='2u5mc'></sub></form><legend id='2u5mc'></legend><bdo id='2u5mc'><pre id='2u5mc'><center id='2u5mc'></center></pre></bdo></b><th id='2u5mc'></th></span></q></dt></tr></i><div id='2u5mc'><tfoot id='2u5mc'></tfoot><dl id='2u5mc'><fieldset id='2u5mc'></fieldset></dl></div>

            <small id='2u5mc'></small><noframes id='2u5mc'>

              <tbody id='2u5mc'></tbody>
              <bdo id='2u5mc'></bdo><ul id='2u5mc'></ul>
                <legend id='2u5mc'><style id='2u5mc'><dir id='2u5mc'><q id='2u5mc'></q></dir></style></legend>
                本文介绍了PHP - 在文本中查找链接的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个函数可以转换像 'www.example.com' 和 'http://example.com' 在超链接中.它还处理子域,例如'http://sub.example.com'.

                I have got a function that converts strings like 'www.example.com' and 'http://example.com' in hyperlinks. It also deals with subdomains e.g. 'http://sub.example.com'.

                但是它失败了 - http://www.example.com' 并输出以下内容

                But it fails with this one - http://www.example.com' and outputs the following

                <a href="http://<a href="http://www.chemica.ru">www.chemica.ru</a>">http://<a href="http://www.chemica.ru">www.chemica.ru</a></a>
                

                请问,有人可以帮忙吗?问题是http://"和www".两者都具有不同的转换方式.

                function makeLinks($text){ 
                 $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '<a href="\1">\1</a>', $text); 
                 $text = eregi_replace('(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '<a href="http://\1">\1</a>', $text);
                 $text = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})', '<a href="mailto:\1">\1</a>', $text); 
                 return $text; 
                }
                

                推荐答案

                只需写入视图页面(不需要任何库或辅助函数):

                just write to your view's page (you dont need any library or helper function) :

                $text = "Good Site is http://masalahkita.com";
                $link = preg_replace("/([w]+://[w-?&;#~=./@]+[w/])/i","<a target="_blank" href="$1">$1</a>", $text);
                
                echo $link;
                

                这篇关于PHP - 在文本中查找链接的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                <legend id='ClU22'><style id='ClU22'><dir id='ClU22'><q id='ClU22'></q></dir></style></legend>
              • <small id='ClU22'></small><noframes id='ClU22'>

              • <tfoot id='ClU22'></tfoot>
                  • <bdo id='ClU22'></bdo><ul id='ClU22'></ul>

                    <i id='ClU22'><tr id='ClU22'><dt id='ClU22'><q id='ClU22'><span id='ClU22'><b id='ClU22'><form id='ClU22'><ins id='ClU22'></ins><ul id='ClU22'></ul><sub id='ClU22'></sub></form><legend id='ClU22'></legend><bdo id='ClU22'><pre id='ClU22'><center id='ClU22'></center></pre></bdo></b><th id='ClU22'></th></span></q></dt></tr></i><div id='ClU22'><tfoot id='ClU22'></tfoot><dl id='ClU22'><fieldset id='ClU22'></fieldset></dl></div>
                        <tbody id='ClU22'></tbody>