每次加载html文件时如何调用php脚本? [英] How do I call php script each time html file loads?

查看:49
本文介绍了每次加载html文件时如何调用php脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有统计网站访问量的php脚本.每当我的html页面加载时,我都需要调用该脚本.

I have php script that counts web site visits. I need to call that script each time my html page loads.

我该怎么做?

推荐答案

如果是PHP页面,则可以使用 require include 参见 include

If it's a PHP page, you can include/require a page in to another PHP page using require or include see include and require documentation

require("counting_script.php");
// or
include("counting_script.php");

如果它是纯HTML文件,则可以考虑使用iFrame加载其他页面,请参见教程

If it's a purely HTML file, then you could consider using an iFrame to load your other page see tutorial

<iframe src="page_counter.php"></iframe>

或者,如果您知道jQuery,则可以对计数页面进行ajax调用(使用jQuery).请参见文档

Or if you know jQuery, you could make an ajax call (using jQuery) to your counting page. See documentation

$.get('page_counter.php', function(data) {
  alert('Counter page was called');
});

这篇关于每次加载html文件时如何调用php脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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