This example describes how HTML static pages invoke PHP files. Share to everyone for your reference. The specific methods are as follows:
Static page seems to be unable to directly call the PHP file, but can use JS call way to invoke the PHP file, of course, can also use Ajax invoke PHP file, the following to introduce you:
Give a simple example to illustrate:
You can pass action=test arguments to b.php, as in the following sentence in the page a.html.
JavaScript code
Copy Code code as follows:
<script type= "Text/javascript" src= "B.php?action=test" ></script>
There is a section of PHP code in b.php:
Copy Code code as follows:
<?php
$action =$_get[' action '];
echo "document.write" ("$action."); n ";
?>
When the a.html file is executed, the b.php file is invoked and the output of the b.php file is executed as a JS statement, and the content is the value of the parameter action passed by JS, which is the value of the action received 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, the PHP file does not contain pass parameters
Copy Code code as follows:
$ ("#myID"). Load ("test.php");
2, load a php file, the php file contains a passing parameter
Copy Code code as follows:
$ ("#myID"). Load ("test.php", {"name": "Adam"});
3. Load a PHP file that contains multiple pass parameters. Note: The parameters are separated by commas
Copy Code code as follows:
$ ("#myID"). Load ("test.php", {"name": "Adam", "Site": www.jb51.net});
The imported PHP file contains a pass-through parameter, similar to the following: Test.php?name=adam&site=www.jb51.net
4. Load a php file, the php file with an array as the passing parameters
Copy Code code as follows:
$ ("#myID"). Load ("test.php", {' myinfo[] ', ["Adam", www.jb51.net});
The imported PHP file contains an array pass parameter.
I hope this article will help you with your PHP program design.