Use js to call PHP content in HTML

Source: Internet
Author: User

Introduction: This is a detailed page for using js to call PHP in HTML. It introduces PHP, related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 323141 'rolling = 'no'>

We often see a lot of website statisticsCodeThey are all displayed in the form of JS calls. Let's take a look at how the instance works.

<? PHP
$ Countfile = "num.txt ";
// Define that the file written by the counter is count.txt under the current directory. Then, we should test whether the file can be opened.

If ($ fp = fopen ($ countfile, "R +") = false) {// open the file in read/write mode. If the file cannot be opened, exit.
Printf ("opening file % s failed! ", $ Countfile );
Exit;
}
Else
{
// If the file can be opened normally, the data in the file will be read, assuming 1
$ COUNT = fread ($ FP, 10 );
// Read 10-Bit Data
$ COUNT = $ count + 1;
Fclose ($ FP );
// Close the current file
$ Fp = fopen ($ countfile, "W + ");
// Open the file in overwrite Mode
Fwrite ($ FP, $ count );
// Write new data after 1
Fclose ($ FP );
// Close the file

Echo 'document. Write ("'. $ count.'") n ';
// Output data in Javascript format

}
?>
In the HTML file, JS calls the method.
<HTML>
<Head>
<Title> example of page separation counter </title>
</Head>
<Body>
Hello, you are the first
<Script language = "JavaScript" src = "filecount. php">
// Pay attention to the server and directory path of the PHP counter when referencing.
</SCRIPT>
Visitor
</Body>
</Html>

More articles about "using js to call PHP content in HTML"

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/323141.html pageno: 16.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.