JS calls PHP and PHP calls JS. The editor makes the following summary, hoping to help everyone;
First of all: JS method Call the PHP file and get the value inPHP; the following example illustrates:
For example, in the page test_1,is called with the following sentence:
test.php file:
When executing thetest.php file, Thetest_1.php file will be called, and the output of the b.php file will be executed as a JS statement,
so here it will A prompt box pops up, the content is the value of the JS variable jstext, which is the value assigned to jstext in the PHP file.
Summary: Use JS to call files in HTML to call PHP file, the output of the PHP file will be used as JS code by the calling page.
PHPcalls the valueinJS
There is such a piece of code in the test.php page:
echo ""; ?>
php calls the method (function) in js
It is basically the same as the second case Similarly, use echo scripts to implement JS calls
test();"; ?>
JS calls PHP variables (1)
(2)
JS calls PHP function
The above is the detailed content of Examples of methods for JS to call PHP and PHP to call JS. For more information, please follow other related articles on the PHP Chinese website!