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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -