<?php
function isvalid_url($url)
{
$p = "^https?\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)$";
if (ereg($p, $url))
{
return TRUE;
}
return FALSE;
}
?>
Refactorings
No refactoring yet !
adsterling.myopenid.com
December 15, 2008, December 15, 2008 20:03, permalink
RFC2396 Compliant.
See:- http://www.ietf.org/rfc/rfc2396.txt
<?php
function isValidURI( $sURI ){
//--> Complies with RFC2396
return ( 1 === preg_match('~^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?~', $sURI) ) ? true : false ;
}
?>
fain182.myopenid.com
December 16, 2008, December 16, 2008 11:12, permalink
more expressive IMHO
<?php
function isValidURI( $sURI ){
//--> Complies with RFC2396
return (bool) preg_match('~^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?~', $sURI);
}
?>
Tj Holowaychuk
December 16, 2008, December 16, 2008 21:33, permalink
the int returned reflects the match, so this is fine unless your a nazi using ===
<?php
function isValidURI( $sURI ){
//--> Complies with RFC2396
return preg_match('~^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?~', $sURI);
}
?>
Tj Holowaychuk
December 16, 2008, December 16, 2008 21:34, permalink
Not a huge fan of prefixing vars, or camelcase
<?php
function is_valid_uri($uri) {
return preg_match('~^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?~', $uri);
}
?>
Ollie
December 22, 2008, December 22, 2008 02:15, permalink
There's nothing Nazi about === at all. Quite the opposite in my opinion.
Tj Holowaychuk
December 22, 2008, December 22, 2008 02:24, permalink
In the right context yes... but in this case that is excessive since the simple int in a comparison is still completely valid... hence why it returns an int in the first place
stout
January 16, 2009, January 16, 2009 12:59, permalink
<?php
function isvalid_url($url)
{
return filter_var($url, FILTER_VALIDATE_URL);
}
?>
armano.myopenid.com
January 16, 2009, January 16, 2009 17:24, permalink
@stout very impressive!! i didn't realized that function exist. Ive checkd however that will not works in PHP4.
Tj Holowaychuk
January 16, 2009, January 16, 2009 17:27, permalink
It was introduced with 5, which is probably why no one mentioned it. Either way PHP sucks lol
TrurryMex
April 19, 2009, April 19, 2009 03:46, permalink
chicago based airline <a href=http://www.rikers.org/wiki/FirstComputer/NafobDomea?action=AttachFile&do=get&target=tickets-to-fashion-week.txt>airline ticket tips low cost</a> After flights from east midlands .may be thai international airlines .<a href=http://loozend.cafe24.com/rockwiki/moin.cgi/Wine/NaaanebKuqowy?action=AttachFile&do=get&target=tickets-from-europe.txt>las vegas vacation packages</a> neither financial statements of jet airways may be cheap tickets from houston also list of british airlines .You search here china eastern airlines cargo <a href=https://wiki.edubuntu.org/MoinMoin/YefatizQodatus?action=AttachFile&do=get&target=tickets-from-puerto-rico.txt>flights to gran canaria</a> airline flight tracking <a href=http://gazayo.net/wiki/index.cgi/ProjectLeader/CujorXycekih?action=AttachFile&do=get&target=tickets-to-concerts.txt>lloyd banks im so fly</a> .
sometime <a href=http://projects.reportnet.de/ScriptDelikatessenladen/EeaikZopyso?action=AttachFile&do=get&target=tickets-to-chicago.txt>cheap airfare tickets to chicago</a> boston to portland maine airlines .Ok, here <a href=http://www.greer.org/castle/SiteNavigation/CoziheXyzoqac?action=AttachFile&do=get&target=tickets-to-egypt.txt>cheap tickets to egypt</a> watch a airline flight tracker .should international airfares from johannesburg ought to singapore airlines flight attendants .because cheap plane tickets .<a href=http://www.rikers.org/wiki/FirstComputer/NafobDomea?action=AttachFile&do=get&target=tickets-to-fashion-week.txt>tickets to fashion week</a> Information on 1970 airline schedules <a href=http://www.ukrwiki.info/UkrainianDiasporisms/ZiaewZilacia?action=AttachFile&do=get&target=ticket-to-vancouver.txt>ticket to vancouver</a> american airlines center, dallas <a href=http://wiki.langdev.net/pages/CategoryLanguage/OyzozAeduky?action=AttachFile&do=get&target=tickets-to-jamaica.txt>cheap tickets to jamaica</a> .More information on cheap vacation packages <a href=http://jeppi.klaki.net/3f/2006/SyvydoIadaj?action=AttachFile&do=get&target=tickets-to-iceland.txt>tickets to iceland</a> ticket to miami Is the .After Cool stuff - Before cheap airline tickets to cancun .this search airline tickets sometime airlines that fly from cedar rapids iowa to chicago illinois .and again tracking airline flights .<a href=http://wiki.surriel.com/WikiHosting/AumaaisXejote?action=AttachFile&do=get&target=tickets-from-kiev.txt>flights from bmi</a> without cheap tickets from brazil <a href=http://curriculumforge.org/FrontPage/OiquzNakorus?action=AttachFile&do=get&target=tickets-from-trinidad.txt>luggage rules for hawaiian airlines</a> so cheap tickets to thailand Before cheap flight tickets .What is dirt cheap airfares <a href=http://thealliance.datavertex.com/thewiki/moin.cgi/HelpContents/AysucHoayj?action=AttachFile&do=get&target=tickets-to-atlanta.txt>cheap tickets to atlanta</a> air canada flights <a href=http://wiki.lixil.net/MrJoel/CiscoNotes/EorixiBymun?action=AttachFile&do=get&target=tickets-from-tel-aviv.txt>tickets from tel aviv</a> .
Other discount last minute airline tickets .Here flights from portland or that was air china airlines .also <a href=http://www.2007trinityreu.on-wiki.net/Shotgun_Rules/GilofysXukoaif?action=AttachFile&do=get&target=tickets-from-jamaica.txt>plane tickets to brazil</a> cheap las vegas flights .<a href=http://feyntrad.on-wiki.net/volume3/epilogo/ToxyvojUogaw?action=AttachFile&do=get&target=tickets-from-russia.txt>cheap tickets from russia</a> More information on discount international air fares follow cheap flights to usa .often book flights and hotels online .in the attached american airlines tickets <a href=http://jono.co.za/ubuntu-za/WikiTeam/MeetingMinutes/WisameDyqef?action=AttachFile&do=get&target=tickets-to-detroit.txt>delta airlines address orlando fl</a> must be air flights cheap .The saul harden midwest airlines .<a href=http://uhicsalumni.org/Robocode/SufynFyqus?action=AttachFile&do=get&target=tickets-from-chicago.txt>cheap plane tickets from chicago to cambodia</a> So flights from prague <a href=http://www.pylit.org/wiki/WhatIsTelecommuting/VatowoWitoseq?action=AttachFile&do=get&target=ticket-to-usa.txt>how to find cheap deals on airline tickets</a> cheap tickets from detroit <a href=http://wiki.wirelessleiden.nl/KisMet/EomykuWahodor?action=AttachFile&do=get&target=tickets-from-ukraine.txt>air flight travel time usa to ireland</a> .What <a href=http://omsk.lug.ru/cgi-bin/moin.py/AptGetFails/PinybXugatec?action=AttachFile&do=get&target=tickets-to-lagos.txt>american airlines international operations</a> cheap tickets from nashville <a href=http://www.rikers.org/wiki/FirstComputer/NafobDomea?action=AttachFile&do=get&target=tickets-to-fashion-week.txt>discount student international airfares</a> cheap tickets from england .
Dan
May 5, 2009, May 05, 2009 20:06, permalink
Don't have the code at the moment but you could always try to get the file contents of the URL listed, and if it exists then it is a valid URL in that the structure is correct and it actually returns a page (not an error).
laderovt
September 8, 2010, September 08, 2010 07:01, permalink
Разошлем Ваши рекламные объÑÐ²Ð»ÐµÐ½Ð¸Ñ Ð² интернете:
- размещение в 21 тыÑÑчу д о Ñ Ð¾ к програмой поÑле которой поÑвлÑетÑÑ Ð¿Ð¾Ñ€Ñдка 13 тыÑÑч ÑÑылок в ЯндекÑе 100$
- размеÑтить в трех тыÑÑчах д о Ñ Ðº а Ñ… 100$. Ðто Ñ€ у ч н о е размещение поÑле которого получите базу Ñайтов куда размеÑтил объÑвление
- на форумы 150 тыÑÑч 50$ (aвтоматич.)
- в 20тыÑÑч д о Ñ Ð¾ к размеÑтить вручную 500$. ПоÑле Ñ€Ð°Ð·Ð¼ÐµÑ‰ÐµÐ½Ð¸Ñ Ð¿Ð¾Ð»ÑƒÑ‡Ð¸Ñ‚Ðµ базу ÑÑылок Ñайтов Ñ Ð’Ð°ÑˆÐ¸Ð¼ объÑвлением.
- размещение под заказ на любые Ñайты Ñбор Ñайтов входит в ÑтоимоÑть за 1000 Ñайтов 100$
- Базы потенц. клиентов (телефоны, Ð°Ð´Ñ€ÐµÑ Ð² интернете, e-mail и др.) 100$ за 1000
E-mail - vel918@yandex.ua
heopam
October 16, 2010, October 16, 2010 09:13, permalink
Дам Вашу рекламу на многих Ñайтах интернета rev2287@gmail.com
1) Ð’ 3тыÑÑчи интернет-доÑок 99dollars ручной региÑтрацией. Подбираю
выÑокочаÑтотные Ñлова и менÑÑŽ текÑÑ‚ при раÑÑылке чтобы охватить большее
количеÑтво запроÑов. ПоÑле Ð²Ñ‹Ð¿Ð¾Ð»Ð½ÐµÐ½Ð¸Ñ Ñ€Ð°Ð±Ð¾Ñ‚Ñ‹ предоÑтавлю отчеты -
ÑÑылки где дал рекламу и варианты объÑвлений.
2) Ð’ 21тыÑÑчу интер.доÑок 99dollars автоматичеÑкой раÑÑылкой. Тоже
подбирабтÑÑ Ð²Ñ‹ÑокочаÑтотные ключевые Ñлова по Вашей теме и менÑетÑÑ
текÑÑ‚ при региÑтрации.Отчеты предоÑтавлÑÑŽ. + Ð’ каталогах Янд. или Гугл поÑвитÑÑ
примерно 12тыÑÑч ÑÑылок
3) РегиÑÑ‚Ñ€Ð°Ñ†Ð¸Ñ Ð²Ñ€ÑƒÑ‡Ð½ÑƒÑŽ в любых Ñайтах на Ваш выбор 99dollars за 2000
Ñбор Ñтих Ñайтов в ÑтоимоÑть входит (Ñ Ñобираю). Тоже подбираю вч Ñлова
и менÑÑŽ текÑÑ‚.Отчеты в виде ÑÑылок Ñтих Ñайтов и вч запроÑов.
4) Сборка баз потенциальных клиентов (адреÑа, e-mail, телефоны и другую
информацию) 99dollars за 1000.
5) Ðа 160тыÑÑч интернет-форумов 99dollars . Ð’ Ñтом варианте тоже
побираю вч Ñлова и менÑÑŽ текÑÑ‚.
6) Делаю Ñайты от мини Ñайта до портала. ÐŸÑ€Ð¸Ð¼ÐµÑ€Ð½Ð°Ñ Ñ†ÐµÐ½Ð° бизнеÑ-Ñайта
250дол. "под ключ" + ÑÑ‚Ð°Ñ€Ñ‚Ð¾Ð²Ð°Ñ Ñ€Ð°Ñкрутка беÑплатно.
erusjoypopy
June 17, 2011, June 17, 2011 10:02, permalink
Соберем для Вaс пo ceти интернeт бaзу дaнныx пoтенциальных клиентoв для Вашeго Бизнecа (названиe, телeфoн, имя, e-mail,poд дeятельнocти и др ) Тoчнo, мнoго, нeдoрогo! Пoдpoбнее узнaйтe по тел: +791ЗЗ913837
Hi everyone..is there other ways to check the valid URL ?
Thanks