Static HTML method of invoking PHP files,
Static page seems to be unable to directly invoke the PHP file, but you can use the JS call method to invoke PHP files, of course, you can also use Ajax to call PHP files, the following to introduce you:
Give a simple example to illustrate:
You can pass action=test parameters to b.php, as in the following sentence in page a.html.
JavaScript code
There is a PHP code in b.php:
When executing the a.html file, the b.php file is called and the output of the b.php file is executed as a JS statement, which is the value of the parameter action of the JS Pass, which is the value of the action accepted in the PHP file.
The load function of jquery 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 transfer parameters
$ ("#myID"). Load ("test.php");
2, load a php file, the PHP file contains a pass parameter
$ ("#myID"). Load ("test.php", {"name": "Adam"});
3. Load a PHP file that contains multiple pass parameters. Note: separated by commas between parameters
$ ("#myID"). Load ("test.php", {"name": "Adam", "Site": Www.shouce.ren});
The imported PHP file contains a pass-through parameter, similar to: Test.php?name=adam&site=www.shouce.ren
4. Load a PHP file with an array as the pass parameter
$ ("#myID"). Load ("test.php", {' myinfo[] ', ["Adam", Www.shouce.ren});
The imported PHP file contains an array pass-through parameter.
1 JS way to call PHP file and get the value in PHP
Give a simple example to illustrate:
As in the page a.html the following sentence is called:
There is a PHP code in b.php:
When the a.html file is executed, the b.php file is called and the output of the b.php file is executed as a JS statement, so a prompt box pops up with the value of the JS variable jstext, which is the value assigned to Jstext in the PHP file.
Summary:
In the HTML with the JS call file to the PHP file, the output of the PHP file will be called the page as JS code to use.
2 PHP calls the value in JS
There is a piece of code in the z.php page:
3 PHP calls the method (function) in JS
4 JS Call PHP variable
(1)
$userId = 100;
?>
(2)
$url = ' changed URLs '; Defining variables
?>
5-------------------------------
6 Write your own JS and PHP call each other
1.php content:
PHP a good way to invoke JS file
Ok ("aaaaaa!");
2.php content:
php$userid=;? >"text" name="userid" id="userid " value=
" "> PHP
if( $_get["action"]=="OK " " I ' m ok! " ;} Else "I ' m not ok! " ;}? >
Please Click
http://www.bkjia.com/PHPjc/1070669.html www.bkjia.com true http://www.bkjia.com/PHPjc/1070669.html techarticle static HTML calls the Php file method, static page seems to be unable to directly invoke the PHP file, but can use the JS call method to invoke the PHP file, of course, you can also use ...