How to differentiate domains from longer URLs in PHP? -


i receive urls php form _post method.

i sure urls because jquery validate plugin tests them before sending.

then process them in php.

however, want make sure :

domain.com or domain.com/

end /.

but, want make sure :

domain.com/page or domain.com/page/ or domain.com/dir/page/ or domain.com/page.html

end without /.

i found : php: how add trailing slash absolute url quite helpful.

i use :

$rawarrival = $_post["arrival"];  $url = parse_url($rawarrival);  if(!isset($url['path'])) $url['path'] = '/'; $arrival = $url['scheme']."://".$url['host'].$url['path']; 

nevertheless, still can't make long url (longer domain) without "/".

how should twist make work ?

thank you.

look @ last character?

if (substr($url["path"], -1, 1) === "/") {     $url["path"] = substr($url["path"], 0, -1); } 

(untested)


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -