如何在本地主机上正确设置baseurl



我有一个php文件verify.php在一个名为emailtest的文件夹在本地主机。我正在实现一个电子邮件验证脚本。但我有注册后通过电子邮件发送的激活url的问题。看一下:

define("BASE_PATH", dirname('http://localhost:8888/'))
$url = BASE_PATH . '/emailtest'.'/verify.php?email=' . urlencode($email) . "&key=$encode";

在发送的电子邮件中,我收到了一个链接,看起来像这样(这是不可打开的):

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

但我真正想要的是这个

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

如何正确设置url ?

只是为了将来参考,我打错了链接,应该是:

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

尝试define("BASE_PATH", "http://localhost:8888") -我认为您不需要使用dirname()功能

好吧,这对我来说很有效,这也是动态的。

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

使用全局SERVER

最新更新