搜索内容

Typecho获取当前页面网址链接

· · 约 1 分钟
0 0

在源码var/Typecho/Request.php有个getRequestUrl函数可以获取当前网址链接,使用方法如下:

<?php echo $this->request->getRequestUrl(); ?>

当然使用如下使用原生php语法写也是可以的

function thisPageUrl() {
    return (isset($_SERVER['HTTPS']) ? 'https://' : 'http://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
}
echo thisPageUrl();

发表评论

邮箱不会公开。必填项已用 * 标注。