如何在localhost上正确设置baseurl

I have a php file verify.php in a folder called emailtest on localhost. I'm implementing an email verification script. But i'm having issues with the activation url that is emailed after registration. Take a look:

define("BASE_PATH", dirname('http://localhost:8888/'))

$url = BASE_PATH . '/emailtest'.'/verify.php?email=' . urlencode($email) . "&key=$encode";

In the email sent, i'm getting a link that looks like this(which is unopenable):

    `"http:/emailtest/verify.php?email=lexon4ril%40yahoo.com&key=58a9a..."`

But what i really want is this

`http:localhost:8888/emailtest/verify.php?email=lexon4ril%40yahoo.com&key=58a9a...`

How can i properly set the url.?

UPDATE Just for future reference i mistyped the link, should be:

`http://localhost:8888//emailtest/verify.php?email=lexon4ril%40yahoo.com&key=58a9a...`

Try define("BASE_PATH", "http://localhost:8888") - I don't think you need to use dirname() function.

Well, this works for me and this is dynamic too.

$url = $_SERVER['HTTP_HOST'].  '/emailtest'.'/verify.php?email=' . urlencode($email) . "&key=$encode";

Made use of the global SERVER.

Hope this works for you.