Heim  >  Artikel  >  Backend-Entwicklung  >  在HTML中利用js调用php的内容_PHP教程

在HTML中利用js调用php的内容_PHP教程

WBOY
WBOYOriginal
2016-07-13 17:40:00805Durchsuche

        我们经常会看到很多网站的统计代码都是以js调用的形式显示的,下面我们就来看看那如何实例的吧。

  1. $countfile = "num.txt";//定义计数器写入的文件是当前目录下count.txt,然后我们应当测试该文件能否打开
  2. if (($fp = fopen($countfile, "r ")) == false) { //用读写模式打开文件,若不能打开就退出
  3.         printf ("打开文件 %s 失败!",$countfile);
  4.         exit;
  5. }else{
  6.         $count = fread ($fp,10);//如果文件能够正常打开,就读入文件中的数据,假设是1
  7.         $count = $count 1; //读取10位数据
  8.         fclose ($fp);//关闭当前文件
  9.         $fp = fopen($countfile, "w ");//以覆盖模式打开文件
  10.         fwrite ($fp,$count);//写入加1后的新数据
  11.         fclose ($fp);//并关闭文件
  12.         echo document.write(".$count.")n;//用javascript形式输出数据
  13. }
  14. ?>
  15. 在html文件里面js调用方法。
  16. 页面分离计数器范例
  17. 您好,您是第
  18. 位访客

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/486253.htmlTechArticle我们经常会看到很多网站的统计代码都是以js调用的形式显示的,下面我们就来看看那如何实例的吧。 ?PHP $countfile = "num.txt";//定义计数器写...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn