The PHP file is called on an html static page,
This example describes how to call a PHP file on an html static page. Share it with you for your reference. The specific method is as follows:
The static page does not seem to be able to directly call the PHP file, but you can use js to call the PHP file. Of course, you can also use ajax to call the PHP file. Here we will introduce it to you:
Here is a simple example:
For example, you can call the following statement in page a.html to pass the parameter action = test to B. php.
Javascript code
Copy codeThe Code is as follows: <script type = "text/javascript" src = "B. php? Action = test "> </script>
There is such a php code in B. PHP:
Copy codeThe Code is as follows: <? Php
$ Action = $ _ GET ['action'];
Echo "document. write ('". $ action. "'); n ";
?>
B. PHP file, and. the output of the PHP file is executed as a JS statement. The content is the value of the parameter action passed by JS, that is, the value of the action accepted in the PHP file.
Jquery's load function is a call that requests another file and loads it into the current DOM.
1. Load a PHP file without passing parameters.
Copy codeThe Code is as follows: $ ("# myID"). load ("test. php ");
2. Load a PHP file that contains a passing Parameter
Copy codeThe Code is as follows: $ ("# myID"). load ("test. php", {"name": "Adam "});
3. Load a PHP file that contains multiple passing parameters. Note: parameters are separated by commas (,).
Copy codeThe Code is as follows: $ ("# myID"). load ("test. php", {"name": "Adam", "site": www.jb51.net });
// The imported php file contains a passing parameter, similar to: test. php? Name = Adam & site = www.jb51.net
4. Load a PHP file. The php file uses an array as the transmission parameter.
Copy codeThe Code is as follows: $ ("# myID"). load ("test. php", {'myinfo [] ', ["Adam", www.jb51.net });
// The imported PHP file contains an array for passing parameters.
I hope this article will help you with php programming.