Home >Backend Development >PHP Tutorial >PHP and Dreamweaver regular preg_match obtain the top-level domain name

PHP and Dreamweaver regular preg_match obtain the top-level domain name

WBOY
WBOYOriginal
2016-07-29 09:12:151445browse

Dreamweaver

<code>{<span>dede:</span>geturl runphp=<span>'yes'</span>}  
<span>$url</span> = <span>$_SERVER</span>[<span>'HTTP_HOST'</span>];
preg_match(<span>"#[\w-]+\.(com|net|org|gov|cc|biz|info|cn|co)(\.(cn|hk|uk))*#"</span>, <span>$url</span>, <span>$match</span>);
<span>@me</span> =  <span>$match</span>[<span>0</span>];
{<span>/dede:geturl}</span></code>

PHP

<code><span><span><?php</span><span>$url</span> = <span>$_SERVER</span>[<span>'HTTP_HOST'</span>];
preg_match(<span>"#[\w-]+\.(com|net|org|gov|cc|biz|info|cn|co)(\.(cn|hk|uk))*#"</span>, <span>$url</span>, <span>$match</span>);
<span>echo</span><span>$match</span>[<span>0</span>];
<span>?></span></span></code>
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces PHP and Dreamweaver regular preg_match to obtain the top-level domain name, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:nginx配置ajpNext article:Centos7安装nginx