获取PHP中调用网页的URL [英] Get URL of calling webpage in PHP

查看:123
本文介绍了获取PHP中调用网页的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在上一堂课的网站统计引擎.这样的想法是,您只需在网页中嵌入一些代码即可在每次加载页面时调用stats网站,然后stats网站将跟踪您的点击量,这样……就没有突破性的进展.

I am working on a website statistics engine for a class. The idea being that you can simply embed a little code in your web page which will call the stats website on every page load and the stats website will then track your hits and such… nothing ground breaking.

我想做的是能够按网页细分网站点击量.例如,一个人可以在每个页面上包含相同的代码,并且统计网站将知道哪个页面被点击了多少次. PHP中是否有一种方法可以获取调用页面(存在嵌入代码的页面)的URL?我知道如何获取运行PHP代码的页面的URL,而不是调用页面的URL.

What I would like to do is be able to break down website hits by webpage. For instance, a person can include the same code on each page, and the stats website will know which page got hit how many times. Is there a way in PHP to obtain the URL of the calling page (the page on which the embedded code exists)? I know how to get the URL of the page in which the PHP code is running, but not the calling page.

或者,我可能可以使用一些JavaScript将页面URL传递到统计网站,但是需要嵌入的代码越少越好,所以我希望有一个PHP解决方案.

Alternatively, I could probably use some JavaScript to pass the page URL to the stats website, but the less code that needs to be embedded the better so I’m hoping for a PHP solution.

在此先感谢您提供所有帮助!

Thanks in advance for any and all help!

推荐答案

$_SERVER['HTTP_REFERER']将为您提供推荐页面.

$_SERVER['HTTP_REFERER'] will get you the referring page.

这篇关于获取PHP中调用网页的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆