| Conditions | 2 |
| Paths | 2 |
| Total Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | function Url2Link($url) |
||
|
|
|||
| 35 | { |
||
| 36 | $str = ''; |
||
| 37 | //格式一:[url=地址]名称[/url] |
||
| 38 | $patterns = '/\[url=(\S+)\](\S+)\[\/url\]/i'; |
||
| 39 | $replace = '\\1'; |
||
| 40 | $str = preg_replace( $patterns, $replace, $url ); |
||
| 41 | if ( empty($str) ) |
||
| 42 | { |
||
| 43 | //格式二:[url]地址[/url] |
||
| 44 | $patterns = '/\[url\](\S+)\[\/url\]/i'; |
||
| 45 | $replace = '\\1'; |
||
| 46 | $str = preg_replace( $patterns, $replace, $url ); |
||
| 47 | } |
||
| 48 | return($str); |
||
| 49 | } // end of function Url2Link |
||
| 50 | |||
| 71 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.