How do I parse a URL in PHP? -


possible duplicate:
parsing domain url in php

how

http://localhost/ 

from

http://localhost/something/ 

using php

i tried

    $base  = strtok($url, '/'); 

you can use parse_url down hostname.

e.g.:

$url = "http://localhost/path/to/?here=there"; $data = parse_url($url); var_dump($data);  /* array (     [scheme] => http     [host] => localhost     [path] => /path/to/     [query] => here=there ) */ 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -