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
Release: 2016-07-29 09:12:15
Original
1430 people have browsed it

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>
Copy after login

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>
Copy after login
').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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template